它看起来像深度数据的不同映射。
你可以尝试把libfreenect数据为CV ::垫和规模是:
const float scaleFactor = 0.05f;
depth.convertTo(depthMat8UC1, CV_8UC1, scaleFactor);
imshow("depth gray",depthMat8UC1);
您还可以检出本文以及上building OpenNI2上特森TK1。 一旦你有OpenNI的设置和工作,你应该能够从WITH_OPENNI
与cmake
源编译OpenCV。之后,你应该能够直接在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;
}
}