问题描述
我正在使用OpenNI和OpenCV(但没有支持openni的最新代码).如果我只是将深度通道发送到屏幕,它将看起来很暗,很难理解.因此,我想为用户显示一种颜色的深度通道,但无法找到如何做到这一点而又不失准确性的方法.现在,我这样做了:
I'm using OpenNI and OpenCV (but without the latest code with openni support). If I just send the depth channel to the screen - it will look dark and difficult to understand something. So I want to show a depth channel for the user in a color but cannot find how to do that without losing of accuracy. Now I do it like that:
xn::DepthMetaData xDepthMap;
depthGen.GetMetaData(xDepthMap);
XnDepthPixel* depthData = const_cast<XnDepthPixel*>(xDepthMap.Data());
cv::Mat depth(frame_height, frame_width, CV_16U, reinterpret_cast<void*>(depthData));
cv::Mat depthMat8UC1;
depth.convertTo(depthMat8UC1, CV_8UC1);
cv::Mat falseColorsMap;
cv::applyColorMap(depthMat8UC1, falseColorsMap, cv::COLORMAP_AUTUMN);
depthWriter << falseColorsMap;
但是在这种情况下,我得到的输出(丢失细节)比Windows的kinects软件差.因此,我正在寻找具有更好转换效果的OpenNI或OpenCV函数.
But in this case I get worse (loosing details) output than, for instance, kinects software for windows shows me. So I'm looking for a function in OpenNI or OpenCV with a better transformation.
推荐答案
尝试一下:
const float scaleFactor = 0.05f;
depth.convertTo(depthMat8UC1, CV_8UC1, scaleFactor);
imshow("depth gray",depthMat8UC1);
使用该值来获得您满意的结果
Play with the value to get a result you're happy with
这篇关于将Kinects深度转换为RGB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!