kinect2.0 opencv3.2深度图像提取(方式一)
来源:互联网 发布:java定义数组的方法 编辑:程序博客网 时间:2024/06/03 22:39
转载请注明出处:http://blog.csdn.net/mystylee/article/details/77992723
本人的配置:win10 + visual studio 2015 + kinect2.0 + opencv3.2
对于Kinect、opencv的配置不再赘述,网上很多资料。下面是实现调取kinect 深度图像的代码:
#include <Kinect.h>
#include <iostream>
#include <opencv2/highgui.hpp>
using namespace std;
using namespace cv;
char file_name[20];
int a = 0;
int main(void)
{
IKinectSensor * m_pKinectSensor = nullptr;
GetDefaultKinectSensor(&m_pKinectSensor);
m_pKinectSensor->Open();
IDepthFrameSource * m_pDepthSource = nullptr;
m_pKinectSensor->get_DepthFrameSource(&m_pDepthSource);
int depth_height = 0, depth_width = 0;
IFrameDescription * m_pDepthDescription = nullptr;
m_pDepthSource->get_FrameDescription(&m_pDepthDescription);
m_pDepthDescription->get_Height(&depth_height);
m_pDepthDescription->get_Width(&depth_width);
m_pDepthDescription->Release();
IDepthFrameReader *m_pDepthReader = nullptr;
m_pDepthSource->OpenReader(&m_pDepthReader);
IDepthFrame * m_pDepthFrame = nullptr;
UINT16* depthArray = new UINT16[depth_height*depth_width];
Mat depthImg(depth_height, depth_width, CV_8UC1);
while (1)
{
if (m_pDepthReader->AcquireLatestFrame(&m_pDepthFrame) == S_OK)
{
m_pDepthFrame->CopyFrameDataToArray(depth_height * depth_width, depthArray);
for (int i = 0; i < depth_height; i++)//遍历图像
{
for (int j = 0; j < depth_width; j++)
{
depthImg.at<uchar>(i, j) = static_cast<uchar>(depthArray[i * depth_width + j]);
}
}
imshow("depthImg", depthImg);
sprintf(file_name, "depth + %d.jpg", a++);//也可以是其他类型的图片文件。比如.bmp
imwrite(file_name, depthImg);//存储每一帧的深度图片
waitKey(1);
m_pDepthFrame->Release();
}
if (waitKey(30) == VK_ESCAPE)
break;
}
m_pDepthReader->Release();
m_pDepthSource->Release();
m_pKinectSensor->Close();
m_pKinectSensor->Release();
return 0;
}
- kinect2.0 opencv3.2深度图像提取(方式一)
- kinect2.0 opencv3.2 深度图像提取(方式二)
- kinect2.0 opencv3.2 骨骼图像提取
- kinect2.0开发(一) 读取深度图像
- Kinect2.0 mapping 深度相机图像和颜色相机图像
- kinect2.0+opencv获取图像和深度图像
- kinect2.0(二)读取彩色图像
- kinect2.0图像输出综合
- opencv3/C++图像边缘提取
- opencv3.0 图像滤波方式代码实现
- Visual studio 2017+Kinect2.0+opencv3.2.0 配置
- Opencv+Kinect2.0获取BodyIndex图像
- kinect2.0开发笔记(一)搭建环境
- opencv3 背景建模提取前景图像
- 图像分割(一)轮廓提取
- kinect2.0开发笔记(二) 获取彩色图和深度图
- Opencv3.0-python的那些事儿:(一)、Opencv的图像和视频处理基本用法
- opencv3.2 背景提取方法
- 从零开始微信机器人(一):wxpy简介(登录、消息发送、注册回复)
- Glide4.0源码全解析(二),load()背后的故事
- EasyUI动态表头与数据宽度不对应
- Java语言基础学习笔记(二)
- Java命名规范—动力节点Java学院整理
- kinect2.0 opencv3.2深度图像提取(方式一)
- 设计模式——装饰者模式
- JS是一门什么样的语言
- JSP--(Jsp基本语法)
- (Python)矩阵转化
- php生成指定长度的任意字符串
- Mysql取分组后前N个值
- 《Python基础教程》读书笔记(4)之第9章魔法方法、属性和迭代器(关键词:Python/魔法方法/属性/迭代器)
- 防止SQL注入和XSS攻击Filter