当前位置:网站首页>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
边栏推荐
- MySQL事务
- QT信号槽总结-connect函数错误用法
- 每天睡前30分钟阅读Day6_Day6_Date_Calendar_LocalDate_TimeStamp_LocalTime
- Read Day6 30 minutes before going to bed every day_ Day6_ Date_ Calendar_ LocalDate_ TimeStamp_ LocalTime
- Difference between redis serialization genericjackson2jsonredisserializer and jackson2jsonredisserializer
- int与string、int与QString互转
- Chrome用户脚本管理器-Tampermonkey 油猴
- PI control of three-phase grid connected inverter - off grid mode
- In depth analysis of how the JVM executes Hello World
- Chrome browser plug-in fatkun installation and introduction
猜你喜欢
Chrome video download Plug-in – video downloader for Chrome
Elastic Stack之Beats(Filebeat、Metricbeat)、Kibana、Logstash教程
Microservice practice | load balancing component and source code analysis
每天睡前30分钟阅读Day6_Day6_Date_Calendar_LocalDate_TimeStamp_LocalTime
Beats (filebeat, metricbeat), kibana, logstack tutorial of elastic stack
定时线程池实现请求合并
三相逆变器离网控制——PR控制
Required request body is missing: (cross domain problem)
深入剖析JVM是如何执行Hello World的
ZK configuration center -- configuration and use of config Toolkit
随机推荐
Matplotlib swordsman line - layout guide and multi map implementation (Updated)
图像识别-数据采集
Typeerror: X () got multiple values for argument 'y‘
Inverter Simulink model -- processor in the loop test (PIL)
MySQL事务
Web security and defense
How to choose between efficiency and correctness of these three implementation methods of distributed locks?
Alibaba /热门json解析开源项目 fastjson2
定时线程池实现请求合并
2837xd code generation - stateflow (4)
Idempotent design of Internet API interface
C语言之数据插入
Micro service practice | introduction and practice of zuul, a micro service gateway
Activity的创建和跳转
Microservice practice | teach you to develop load balancing components hand in hand
Statistical learning methods - Chapter 5, decision tree model and learning (Part 1)
BugkuCTF-web24(解题思路及步骤)
Probability is not yet. Look at statistical learning methods -- Chapter 4, naive Bayesian method
Microservice practice | declarative service invocation openfeign practice
Number structure (C language -- code with comments) -- Chapter 2, linear table (updated version)