对于英特尔实感3D摄像头(SR300),pmdGet3DCoordinates相当于什么?

时间:2017-05-15 17:36:43

标签: c++ opencv camera realsense

我正在尝试为英特尔实感3D相机(SR300)编写PMD相机的类似代码。但是,我找不到在realsense SDK中执行相同操作的方法。是否存在此问题,或者您的建议是什么?

pmdGet3DCoordinates(PMDHandle hnd, float * data, size_t size);

示例用法是:

float * cartesianDist = new float[nRows*nCols*3];
res = pmdGet3DCoordinates(hnd, cartesianDist, nCols*nRows*3*sizeOf(float));

我需要此功能才能创建xyzmap,如下面的代码所示:

int res = pmdGet3DCoordinates(hnd, dists, 3 * numPixels * sizeof(float)); 
xyzMap = cv::Mat(xyzMap.size(), xyzMap.type(), dists);

到目前为止,我已经编写了以下代码,我不知道它是否对英特尔实感有任何意义。请随时发表评论。

void SR300Camera::fillInZCoords()
{
    //int res = pmdGet3DCoordinates(hnd, dists, 3 * numPixels * sizeof(float)); //store x,y,z coordinates dists (type: float*)
    ////float * zCoords = new float[1]; //store z-Coordinates of dists in zCoords
    //xyzMap = cv::Mat(xyzMap.size(), xyzMap.type(), dists);
    Projection *projection = pp->QueryCaptureManager()->QueryDevice()->CreateProjection();
    std::vector<Point3DF32> vertices;
    vertices.resize(bufferSize.width * bufferSize.height);
    projection->QueryVertices(sample->depth, &vertices[0]);
    xyzBuffer.clear();

    for (int i = 0; i < bufferSize.width*bufferSize.height; i++) {
        //cv::Point3f p;
        //p.x = vertices[i].x;
        //p.y = vertices[i].y;
        //p.z = vertices[i].z;
        //xyzBuffer.push_back(p);
        xyzBuffer.push_back(cv::Point3f(vertices[i].x, vertices[i].y, vertices[i].z));
    }



    xyzMap = cv::Mat(xyzBuffer);
    projection->Release();
}

1 个答案:

答案 0 :(得分:1)

sts = projection->QueryVertices(depthMap, &pos3D[0]);几乎相同,可以将深度UV贴图转换为真实世界的xyz贴图。

   Status sts = sm ->AcquireFrame(true);


        if (sts < STATUS_NO_ERROR) {
            if (sts == Status::STATUS_STREAM_CONFIG_CHANGED) {
                wprintf_s(L"Stream configuration was changed, re-initilizing\n");
                sm ->Close();
            }
        }

        sample = sm->QuerySample();
        PXCImage *depthMap = sample->depth;
        renderd.RenderFrame(sample->depth);
        PXCImage::ImageData depthImage;
        depthMap->AcquireAccess(PXCImage::ACCESS_READ, &depthImage);
        PXCImage::ImageInfo imgInfo = depthMap->QueryInfo();
        int depth_stride = depthImage.pitches[0] / sizeof(pxcU16);
        PXCProjection * projection = device->CreateProjection();
        pxcU16 *dpixels = (pxcU16*)depthImage.planes[0];
        unsigned int dpitch = depthImage.pitches[0] / sizeof(pxcU16);
        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();
        }