为啥 QueryVertices 中的所有坐标都为零?

Posted

技术标签:

【中文标题】为啥 QueryVertices 中的所有坐标都为零?【英文标题】:Why do all the coordinates from the QueryVertices are zero?为什么 QueryVertices 中的所有坐标都为零? 【发布时间】:2017-05-22 23:53:22 【问题描述】:

对于以下代码:

Reads the depth data from the sensor and fills in the matrix
***/
void SR300Camera::fillInZCoords()

    Image::ImageData depthImage;
    Image *depthMap = sample->depth;
    depthMap->AcquireAccess(Image::ACCESS_READ, &depthImage);
    Image::ImageInfo imgInfo = depthMap->QueryInfo();
    int depth_stride = depthImage.pitches[0] / sizeof(pxcU16);
    Projection * projection = device->CreateProjection();
    unsigned int wxhDepth = depth_width * depth_height;
    Point3DF32* vertices = new Point3DF32[wxhDepth];
    projection->QueryVertices(depthMap, vertices);
    pxcU16 *dpixels = (pxcU16*)depthImage.planes[0];
    unsigned int dpitch = depthImage.pitches[0] / sizeof(pxcU16); /* aligned width */

    for (int k = 0; k < wxhDepth; k++) 
        cout << "xx is " << vertices[k].x << endl;
        cout << "yy is " << vertices[k].y << endl;
        cout << "zz is " << vertices[k].z << endl;
    


我打印的所有内容都为零。在 SDK 文档中告知,为了将深度图像 UV-map 坐标(以像素为单位)转换为以 mm 为单位的真实世界的 xyz-map,请使用 QueryVertices。但是,对我来说它只返回 0。我得到了彩色和深度图像,我不确定出了什么问题。 以下是调试代码的更多信息:

*

-       vertices    0x00000261e4934040 x=0.000000000 y=0.000000000 z=0.000000000  Intel::RealSense::Point3DF32 *
        wxhDepth    307200  unsigned int
-       depthImage.pitches  0x00000075a2da9de0 1280, 0, 0, 0  int[4]
-       planes  0x00000075a2da9df0 0x00000261e7542000 "", 0x0000000000000000 <NULL>, 0x0000000000000000 <NULL>, 0x0000000000000000 <NULL> unsigned char *[4]
+       reserved    0x00000075a2da9dd4 0, 0, 0    int[3]
        format  PIXEL_FORMAT_DEPTH (131072) Intel::RealSense::Image::PixelFormat

*

【问题讨论】:

【参考方案1】:

下面是从Depth image UVmap中获取xyzMap的正确答案:

PXCImage::ImageData depthImage;
depthMap->AcquireAccess(PXCImage::ACCESS_READ, &depthImage);
PXCImage::ImageInfo imgInfo = depthMap->QueryInfo();
depth_width = imgInfo.width;
depth_height = imgInfo.height;
num_pixels = depth_width * depth_height;
PXCProjection * projection = device->CreateProjection();
PXCPoint3DF32 *pos3D = new PXCPoint3DF32[num_pixels];
sts = projection->QueryVertices(depthMap, &pos3D[0]);
if (sts < Status::STATUS_NO_ERROR) 
    wprintf_s(L"Projection was unsuccessful! \n");
    sm->Close();

【讨论】:

以上是关于为啥 QueryVertices 中的所有坐标都为零?的主要内容,如果未能解决你的问题,请参考以下文章

在 Query Vertices() 中获取空值 - Intel Realsense F200

为啥精灵套件中的坐标系会翻转,我可以全局更改吗?

为啥我的着色器中的 GLSL 纹理坐标不是线性的?

为啥我的名字和姓氏都为空?

didUpdateToLocation 调用了两次,好的。为啥 oldLocation 两次都为零?

为啥每个人都为 jQuery 选择 JSON 而不是 XML? [关闭]