- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我想从深度缓冲区中读取。在 OS X 上的 GL 中我可以这样做:
float depth[2][2]; // get 2x2 for bilinear interpolation
glReadPixels(s.x, s.y, /*width*/2, /*height*/2, GL_DEPTH_COMPONENT, GL_FLOAT, depth);
(请注意,使用 iOS 上的 OpenGL ES 时,您无法从深度缓冲区中读取数据)
Metal 的等价物是什么?
看起来我需要做:
_renderPassDescriptor.depthAttachment.storeAction = MTLStoreActionStore;
然后以某种方式通过 CPU 从缓冲区中读取?
虽然也许有更好的方法,因为我只需要一个点(触摸的地方)。片段着色器能否仅存储该点的深度(或双线性插值的 2x2),从而允许我将 storeAction 保留为 MTLStoreActionDontCare?
最佳答案
我将深度存储操作设置为 MTLStoreActionStore
,然后在渲染方法中执行以下操作:
[commandBuffer addCompletedHandler:^(id<MTLCommandBuffer> buffer) {
// We're done! So read from the depth texture.
// Just read the center pixel for now.
MTLRegion region = MTLRegionMake2D(_depthTex.width/2, _depthTex.height/2, 1, 1);
float depth;
[_depthTex getBytes:&depth bytesPerRow:_depthTex.width*4 fromRegion:region mipmapLevel:0];
NSLog(@"read depth: %f", depth);
dispatch_semaphore_signal(block_sema);
}];
这行得通,并被 Apple 开发人员在论坛上确认为“正确的方法”。
请注意,iOS 上的 OpenGL ES 无法从深度缓冲区读取数据。 Metal FTW!
关于iOS/Metal : how to read from the depth buffer at a point?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28424883/
cv2.phase() 函数有问题。我编写了以下代码: img = cv2.imread("1.jpg", 0) cv2.imshow("image", img) img_dx = cv2.Sobel
我正在尝试在 OpenCV 中处理一些图像。具体来说,使用以下函数交换颜色 Pane 。 def green_ble_swap(image) im_rgb = cv2.cvtColor(ima
在Unreal 4.24编辑器中,Actor's Detail面板上的“Rendering”部分中,有一个“Render CustomDepth Pass”复选框,以及一个“CustomDepth S
当我尝试在 Visual Studio 2010 中从 here 运行此代码时.我收到以下错误 OpenCV Error: Assertion failed ((img.depth() == CV_8
我有一个计算旋转和平移矩阵的代码如下: matrix Matrix rt = new Matrix(3, 4); if (positiveCount[0] > positiveCount[1])
我是初学者。我尝试使用Tensorflow进行图像分类,并收到以下错误。我在网上发现了类似的问题,但我听不懂。错误是什么意思?我应该怎么做?请给我一些建议。我使用100个文件(png/15pix,15
我在 this website 上找到了以下代码: import os import os.path import cv2 import glob import imutils CAPTCHA_IMA
这是虚拟更衣室的代码 因此,基本上是为了运行此代码ubuntu 12.04,python 2.7.3,gtk2和opencv 2。它删除背景屏幕,在几乎任何光线条件下检测T恤,替换T恤颜色。编写用于替
我从上面得到这个错误,不知道如何避免它。我的目的是获取屏幕截图,然后对其进行模板匹配,以查看此时屏幕上是否显示图标。到目前为止,它只是图标的位置。我的代码: #include "opencv2/hig
我正在尝试获取使用开放姿势检测到的点的像素坐标值。有人可以告诉我这是识别像素坐标的正确方法吗?还是有其他特定方法可以获取下图中表示为 2 和 5 的像素坐标? 代码: for pair in POSE
我正在尝试使用代码阅读多项选择测试反馈中的答案,但出现以下错误消息: error: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F |
我有一个 Python 算法,它基本上可以帮助找到函数的“深度”: f(a) has a depth of 1 f(g(h(a,b,c),d)),e) has a depth of 3 伪算法是这样的
我正在使用 d3 编写动画,但我似乎无法找到一种方法来轻松确保图形始终出现在其他图形“后面”。 具体来说,我正在处理直线和圆(想象一个有向图),有些线位于圆的顶部,而其他线位于圆的下方,看起来有点糟糕
我正在研究爬虫,需要准确理解“链接深度”的含义。以nutch为例:http://wiki.apache.org/nutch/NutchTutorial depth indicates the link
当做 depth first search在 Directed Graph pre 是什么意思和 post数字? 例如: 如果您从节点 A 开始并按字母顺序排列 Depth First Search你
我在尝试为 Vulkan 构建投影矩阵时遇到了矛盾,并且还没有找到关于投影矩阵如何将 Z 从输入向量映射到输出的解释。映射 x 和 y 很简单。我的理解是 OpenGL 投影矩阵应该将近视锥平面映射到
boolean backtrackDFS(v) { If (SolutionFound(v)) return true; Mark vertex v as reached. f
根据 AIMA(人工智能:现代方法)中的 Norvig 的说法,深度优先算法并不完整(不会总是产生解决方案),因为在某些情况下,下降的子树将是无限的。 另一方面,如果分支因子不是无限的,则广度优先方法
我正在使用谷歌标签管理器对当前站点进行谷歌分析。 现在,我们想知道人们在我们的网站上滚动了多远。 所以我使用了一个名为jquery.scrollDepth.js的插件 $(document).r
我正在用 smallcheck 做我的第一项真正的工作, 我对如何使用 Depth 有点困惑范围。在开始之前,让我先说明我在使用什么 smallcheck为了。 在工作中,我们正在我们自己的内部数据库
我是一名优秀的程序员,十分优秀!