它看起来像深度数据的不同映射。
您可以尝试将 libfreenect 数据放入 cv::Mat 并对其进行缩放:
const float scaleFactor = 0.05f;
depth.convertTo(depthMat8UC1, CV_8UC1, scaleFactor);
imshow("depth gray",depthMat8UC1);
您还可以查看这篇文章以及在 Jetson TK1 上构建 OpenNI2。一旦你安装了 OpenNI 并开始工作,你应该能够从源代码中编译 OpenCV 并WITH_OPENNI
使用cmake
. 之后,您应该能够直接在 OpenCV 中获取深度数据:
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
using namespace cv;
using namespace std;
const float scaleFactor = 0.05f;
int main(){
cout << "opening device(s)" << endl;
VideoCapture sensor;
sensor.open(CV_CAP_OPENNI);
if( !sensor.isOpened() ){
cout << "Can not open capture object 1." << endl;
return -1;
}
for(;;){
Mat depth,depthScaled;
if( !sensor.grab() ){
cout << "Sensor1 can not grab images." << endl;
return -1;
}else if( sensor.retrieve( depth, CV_CAP_OPENNI_DEPTH_MAP ) ) {
depth.convertTo(depthScaled, CV_8UC1, scaleFactor);
imshow("depth",depth);
imshow("depth scaled",depthScaled);
}
if( waitKey( 30 ) == 27 ) break;
}
}