Kinect学习(四):提取深度数据
前面试着提取了Kinect的彩色数据: Kinect学习(三):获取RGB颜色数据 。这次,要试着提取深度数据。 Depth Map(深度图)是包含与视点的场景对象的表面的距离有关的信息的图像或图像通道。其中,Depth Map 类似于灰度图像,只是它的每个像素值是传感器距离物体的实际距离。通常RGB图像和Depth图像是配准的,因而像素点之间具有一对一的对应关系。 先上代码。 #include <Windows.h> #include <iostream> #include <NuiApi.h> #include <opencv2/opencv.hpp> using namespace std ; using namespace cv; int main( int argc, char *argv[]) { cv::Mat img; // 深度图,使用灰度值来表示深度数据,越远灰度越小则越暗 img.create( 480 , 640 , CV_8UC1); // 1、初始化NUI,使用深度数据 HRESULT hr = NuiInitialize(NUI_INITIALIZE_FLAG_USES_DEPTH); if (FAILED(hr)) { cout << "NuiIntialize failed" << endl; return hr; } // 2、定义事件句柄 //