当前位置:网站首页>Kinect DK obtains color RGB images in cv:: mat format (used in openpose)
Kinect DK obtains color RGB images in cv:: mat format (used in openpose)
2022-07-02 09:40:00 【Ignorant dream fireworks】
The main question that this blog solves , obtain Kinect dk Medium color map , And put the color map into openpose in , Get the hand bone points . And then from kinect dk Get the depth value corresponding to each bone point in the depth map of , So as to get three-dimensional bone points . Here are the problems encountered , And corresponding solutions :
problem 1:k4a::image turn CV::Mat
Use cv::Mat The parameterized constructor of
k4a::capture capture;
cv::Mat m_colorMat;
if (m_device.get_capture(&capture)) {
k4a::image m_colorImage = capture.get_color_image();
cv_rgbImage_with_alpha = cv::Mat(m_colorImage.get_height_pixels(), m_colorMat.get_width_pixels(), CV_8UC4,
(void *)m_colorImage.get_buffer(), cv::Mat::AUTO_STEP);
cv::imshow("color", m_colorMat);
}

problem 2:CV::Mat Medium RGBA turn RGB
step[0] Is the number of bytes in a row of elements in a matrix
step[1] Is the number of bytes of an element in the matrix
Openpose The format you want in is RGB( The pictures obtained by the default camera can be recognized normally , Refer to its format )
What you get directly is RGBA
operation : transformation Mat Type of image
cv::cvtColor(m_colorMat, m_colorMat, cv::COLOR_BGRA2BGR); // transformation
problem 3: Picture input to openpose Cannot detect normally
The analysis reason Mat.data There is a problem with the data format in 
k4a::image The data storage in is uint8_t,opencv It uses uchar, Use cv::imshow It can also be displayed normally ( problem 1 The code in will k4a::image Turn into cv::Mat after )
openpose Data for cvInputData, requirement uchar format
Ideas : First, put the data into uint_t To uchar, then k4a::image Turn into cv::Mat
// Data transformation
std::vector<uchar> pos; // spot
int width = m_colorImage.get_width_pixels();
int height = m_colorImage.get_height_pixels();
pos.resize(width * height * 4);
auto depth = m_colorImage.get_buffer();
memcpy(pos.data(), depth, width * height * sizeof(uchar) * 4);
// obtain Mat
m_colorMat= cv::Mat(m_colorImage.get_height_pixels(), m_colorImage.get_width_pixels(), CV_8UC4,
(void *)pos.data(), cv::Mat::AUTO_STEP); // m_colorImage.get_buffer()
// RGBA turn RGB
cv::cvtColor(m_colorMat, m_colorMat, cv::COLOR_BGRA2BGR);
std::move(pos);
result 
边栏推荐
- 2837xd 代码生成——StateFlow(3)
- Customize redis connection pool
- Record personal understanding and experience of game console configuration
- Knife4j 2.X版本文件上传无选择文件控件问题解决
- 道阻且长,行则将至
- MySQL multi column in operation
- Read 30 minutes before going to bed every day_ day4_ Files
- Learn combinelatest through a practical example
- Don't look for it. All the necessary plug-ins for Chrome browser are here
- TD联合Modelsim进行功能仿真
猜你喜欢

三相逆变器离网控制——PR控制

互联网API接口幂等设计

MySQL multi column in operation

Microservice practice | declarative service invocation openfeign practice

三相并网逆变器PI控制——离网模式

图像识别-数据采集

vs+qt 设置应用程序图标

QT qlabel style settings

Don't look for it. All the necessary plug-ins for Chrome browser are here

Required request body is missing: (cross domain problem)
随机推荐
Machine learning practice: is Mermaid a love movie or an action movie? KNN announces the answer
图像识别-数据标注
vs+qt 设置应用程序图标
BugkuCTF-web21(详细解题思路及步骤)
Inverter Simulink model -- processor in the loop test (PIL)
Oracle modifies tablespace names and data files
Int to string, int to qstring
Solutions to Chinese garbled code in CMD window
保存视频 opencv::VideoWriter
Attributes of classfile
int与string、int与QString互转
VIM operation command Encyclopedia
大学生四六级作文模板(自创版,成功跨过六级)
定时线程池实现请求合并
Bold prediction: it will become the core player of 5g
Statistical learning methods - Chapter 5, decision tree model and learning (Part 1)
Oracle modify database character set
企业级SaaS CRM实现
c语言编程题
Redis installation and deployment (windows/linux)