5

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;

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.

4

2 回答 2

2

ghttps://github.com/OpenNI/OpenNI2/blob/master/Samples/Common/OniSampleUtilities.h 链接是直方图均衡的代码。简而言之,它使每个级别的概率相等,并优化了 10,000 个级别和 255 个级别之间的映射。这就是为什么 Kinect 淡黄色地图看起来比天真的 I=255*z/z_range 更好。

注意:不要使用颜色进行可视化,因为人眼对亮度变化比对颜色变化更敏感。因此,使用 255 级亮度时,您将获得比使用 255*255*255 级颜色时更好的对比度。如果您仍然决定使用颜色映射途径,请使用 HSV 颜色空间,您可以在其中操纵色调 0..360 度、值 1..0 并更好地将饱和度设置为最大值。将深度映射到色调和值,转换为 RGB 并显示。比回到直方图均衡;)

于 2013-11-28T09:28:46.347 回答
1

尝试这个:

const float scaleFactor = 0.05f;
depth.convertTo(depthMat8UC1, CV_8UC1, scaleFactor);
imshow("depth gray",depthMat8UC1);

发挥价值以获得您满意的结果

于 2013-07-30T11:46:03.660 回答