我实际上可以从我的ASUS Xtion获得RGB图像,但无法获得任何深度图像。我看到黑色图像而没有出现错误。
OpenNI给出的示例SimpleView有效,所以我猜它不是传感器,而不是库和OpenCV似乎正常工作。
有什么想法吗?
这是我的代码:
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, char* argv[] )
{
cout << "Device opening ..." << endl;
VideoCapture captureStream;
captureStream.open(CV_CAP_OPENNI_ASUS);
if( !captureStream.isOpened() ){
cout << "Can not open capture object." << endl;
return -1;
}
for(;;){
Mat depth;
if( !captureStream.grab() ){
cout << "ASUS Xtion can not grab images." << endl;
return -1;
}else
if( captureStream.retrieve( depth, CV_CAP_OPENNI_DEPTH_MAP) )
imshow("depth",depth);
if( waitKey( 30 ) == 27 ) break;
}
return 0;
}
谢谢!
答案 0 :(得分:1)
OpenCV sample code实际上使用此代码来检索并显示深度图:
Mat depth;
capture.retrieve( depth, CV_CAP_OPENNI_DEPTH_MAP )
const float scaleFactor = 0.05f;
Mat show;
depth.convertTo( show, CV_8UC1, scaleFactor );
imshow( "depth map", show );