它看起來像深度數據的不同映射。
你可以嘗試把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;
}
}