【发布时间】:2012-05-08 10:28:34
【问题描述】:
我用 OpenCV 3.2.1 和 kniect 运行 VS2010。
我正在使用来自here的教程
int main( int argc, char* argv[] ){
VideoCapture capture(CV_CAP_OPENNI); // or CV_CAP_OPENNI
for(;;)
{
Mat depthMap;
Mat bgrImage;
capture.grab();
capture.retrieve( depthMap, CV_CAP_OPENNI_DEPTH_MAP ); // Depth values in mm (CV_16UC1)
capture.retrieve( bgrImage, CV_CAP_OPENNI_BGR_IMAGE );
cout << "rows: " << depthMap.rows << " cols: " << depthMap.cols << endl;
cout << "depth: " << depthMap.at<int>(0,0) << endl;
imshow("RGB image", bgrImage);
if( waitKey( 30 ) >= 0 )
break;
}h
return 0;
运行代码后,我得到以下结果:
靠近墙壁约一米远:
rows: 480 cols: 640
depth: 1157
rows: 480 cols: 640
depth: 1157
rows: 480 cols: 640
depth: 1157
rows: 480 cols: 640
depth: 1157
(Kinect 对着墙,一米多远)
rows: 480 cols: 640
depth: 83690629
rows: 480 cols: 640
depth: 83690629
rows: 480 cols: 640
depth: 83690629
rows: 480 cols: 640
depth: 83690629
rows: 480 cols: 640
depth: 83690629
有人告诉我这些值实际上是两个像素?我真的不明白。
这是我目前的理解:
我抓取了一个深度帧并将其存储在一个名为 depthMap 的矩阵中。矩阵的大小现在是 640*480。我正在使用代码 depthMap.at(0,0) 从第 0 行第 0 列中获取第一个深度值。但我没有返回毫米的结果,而是返回 83690629!这与我期望的最大值 10000 相差甚远
如何将这些值转换为毫米以便使用它们?谢谢
【问题讨论】:
-
也许 Kinect 离墙太近了在一米以下?我知道限制就在附近,如果不是那么精确的话。另见here
-
na 它不低于 1 米,因为我得到相同的值,但在 2-3 米等更远的地方时会稍微高一些。有人对我说,我将 'depthMap.at
(0,0)' 更改为 'depthMap.at (0,0)' 并且结果值为 (83690629) 实际上是两个像素和我应该转换为十六进制? (489102879 = 0x1d271e1f) 不知道他在说什么。但我仍然得到相同的值,不知道如何最好地解释它们。
标签: opencv kinect depth openni