下面还是参考的小斤的博客(似乎是一模一样的,汗)
#include <stdlib.h>
#include <iostream>
#include <string>
#include "OpenNI.h"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace std;
using namespace cv;
using namespace openni;
#define Capture
//#define Show
//检查OPenNI是否初始化成功
void CheckOpenNIError(Status result, string status)
{
if (result != STATUS_OK)
cerr << status << " Error: " << OpenNI::getExtendedError() << endl;
}
int main(int argc, char** argv)
{
#ifdef Capture
Status result = STATUS_OK;
//OpenNI2 image
VideoFrameRef oniDepthImg;
//OpenCV image
cv::Mat cvDepthImg;
char key = 0;
//【1】
// initialize OpenNI2
result = OpenNI::initialize();
CheckOpenNIError(result, "initialize context");
// open device
Device device;
result = device.open(openn