我想通过 Viual Studio 2013 中的 Windows SDK 2.0 从 Kinect V2 获取深度和 RGB 数据。所以我编写了以下代码:
#include <Kinect.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <Windows.h>
#include <iostream>
using namespace std;
const int width = 512;
const int height = 424;
const int colorwidth = 1920;
const int colorheight = 1080;
// Kinect Variables
IKinectSensor* sensor; // Kinect sensor
IMultiSourceFrameReader* reader; // Kinect data source
ICoordinateMapper* mapper;
int main(int argc, char* argv[]) {
if (FAILED(GetDefaultKinectSensor(&sensor))) {
printf("not found sensor");
getchar();
return -100;
}
if (sensor) {
sensor->get_CoordinateMapper(&mapper);
sensor->Open();
sensor->OpenMultiSourceFrameReader(
FrameSourceTypes::FrameSourceTypes_Depth | FrameSourceTypes::FrameSourceTypes_Color,
&reader);
IMultiSourceFrame* framesource;
cout << "Find!!!";
getchar();
return 100;
}
else {
return -100;
}
getchar();
return 10;
}
从逻辑上讲,当我没有将 Kinect 传感器插入笔记本电脑时,控制台中应该打印:“未找到传感器”,不是吗?但是,在控制台打印:“查找!!!”。问题是什么?