对Kinect进行程序的编写,不出现图像,如何办?

hbzsz33 2017-09-29 11:23:12
希望哪位大神能够指教一下这个问题[
...全文
601 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
核桃不好吃 2018-07-28
  • 打赏
  • 举报
回复
记得在循环里加上

if (waitKey(30) == VK_ESCAPE)
break;

这应该是隔30ms采样一次的意思
hbzsz33 2017-09-29
  • 打赏
  • 举报
回复
#include <Kinect.h> //Kinect的头文件 #include <iostream> #include <opencv2\highgui.hpp> //opencv头文件 using namespace std; using namespace cv; int main(void) { IKinectSensor * mySensor = nullptr; GetDefaultKinectSensor(&mySensor); //获取感应器 mySensor->Open(); //打开感应器 IDepthFrameSource * mySource = nullptr; //取得深度数据 mySensor->get_DepthFrameSource(&mySource); int height = 0, width = 0; IFrameDescription * myDescription = nullptr; //取得深度数据的分辨率 mySource->get_FrameDescription(&myDescription); myDescription->get_Height(&height); myDescription->get_Width(&width); myDescription->Release(); IDepthFrameReader * myReader = nullptr; mySource->OpenReader(&myReader); //打开深度数据的Reader IDepthFrame * myFrame = nullptr; Mat temp(height, width, CV_16UC1); //建立图像矩阵 Mat img(height, width, CV_8UC1); while (1) { if (myReader->AcquireLatestFrame(&myFrame) == S_OK) //通过Reader尝试获取最新的一帧深度数据,放入深度帧中,并判断是否成功获取 { myFrame->CopyFrameDataToArray(height * width, (UINT16 *)temp.data); //先把数据存入16位的图像矩阵中 temp.convertTo(img, CV_8UC1, 255.0 / 4500); //再把16位转换为8位 imshow("TEST", img); myFrame->Release(); } if (waitKey(30) == VK_ESCAPE) break; } myReader->Release(); //释放不用的变量并且关闭感应器 mySource->Release(); mySensor->Close(); mySensor->Release(); return 0; }
hbzsz33 2017-09-29
  • 打赏
  • 举报
回复

4,446

社区成员

发帖
与我相关
我的任务
社区描述
图形图像/机器视觉
社区管理员
  • 机器视觉
  • 迪菲赫尔曼
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧