英特尔实感 3D 摄像头 (SR300) 的 pmdGet3DCoordinates 等效项是啥?
Posted
技术标签:
【中文标题】英特尔实感 3D 摄像头 (SR300) 的 pmdGet3DCoordinates 等效项是啥?【英文标题】:What's the equivalent of pmdGet3DCoordinates for Intel RealSense 3D camera (SR300)?英特尔实感 3D 摄像头 (SR300) 的 pmdGet3DCoordinates 等效项是什么? 【发布时间】:2017-05-15 17:36:42 【问题描述】:我现在正在尝试为英特尔实感 3D 摄像头 (SR300) 编写 PMD 摄像头的类似代码。但是,我在 realsense SDK 中找不到做同样事情的方法。是否有针对此的 hack 或您有什么建议?
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);
到目前为止,我已经编写了以下代码,我不知道它对 Intel RealSense 是否有意义。请随时发表评论。
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();
【问题讨论】:
您可能正在寻找mat.reshape() @RickM。请检查更新 从您添加的内容来看,我仍然无法说出您想要什么。我仍然会再次写第一条评论,但这只是一个猜测。你想要这个xyzmap
?矩阵式
格式与 xyzMap (cv::Mat) communities.intel.com/message/474715#474715
【参考方案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();
【讨论】:
以上是关于英特尔实感 3D 摄像头 (SR300) 的 pmdGet3DCoordinates 等效项是啥?的主要内容,如果未能解决你的问题,请参考以下文章