KinectV2(一)—获取彩色图像
V2彩色分辨率:1920x1080
#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;
}
//彩色帧源
IColorFrameSource *myColorSource = nullptr;
hResult = mySensor->get_ColorFrameSource(&myColorSource);
if (FAILED(hResult)) {
cerr << "Error : IKinectSensor::get_ColorFrameSource()" << std::endl;
return -1;
}