KinectV2(二)—获取深度图像
开发环境VS2015+OpenCV3
#include <iostream>
#include <opencv2\imgproc.hpp> //opencv头文件
#include <opencv2\calib3d.hpp>
#include <opencv2\highgui.hpp>
#include <Kinect.h> //Kinect头文件
using namespace std;
using namespace cv;
int main(void)
{
//初始化Kinect
IKinectSensor* mySensor;
HRESULT hResult = S_OK;
hResult = GetDefaultKinectSensor(&mySensor);
if (FAILED(hResult)) {
cerr << "Error : GetDefaultKinectSensor" << std::endl;
return -1;
}
hResult = mySensor->Open();
if (FAILED(hResult)) {
cerr << "Error : IKinectSensor::Open()" << std::endl;
return -1;
}
//深度帧源
IDepthFrameSource * myDepthSource = nullptr;
hResult = mySensor->get_DepthFrameSource(&myDepthSource);
if (FAILED(hResult)) {
cerr << "Error : IKinectSensor::get_DepthFrameSource()" << std::endl;
return -1;
}
//深