获得没有颜色的红外线 [英] Getting Infrared without the color
问题描述
我试过了https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CameraFrames但红外线图像是蓝色和红色。
I tried https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CameraFrames but the infrared image is blue and red.
我试图将调色板更改为黑白,但结果不太好。
I tried to change the color palette to black and white, but the result is not nice.
在SDK中浏览器(Kinect for Windows)v2.0,有一个名为"Infrared Basics-WPF"的样本,你可以在黑暗中看得很清楚。
In the SDK Browser (Kinect for Windows) v2.0, there is a sample called "Infrared Basics-WPF", and you can see very clearly in the dark.
是否有办法让那个预览但是在CameraFrames项目中?
Is the a way to have that preview but in the CameraFrames project?
谢谢
推荐答案
你好,
从WPF样本直接应用算法的问题是,它使用Gray32像素格式进行输出。 UWP根本不支持这种像素格式,用于 显示的位图必须是(afaik)BGRA8格式。
Issue with straightforward application of algorithm from WPF sample is, that it uses Gray32 pixel format for output. This pixel format is not supported in UWP at all and Bitmaps used for display must be (afaik) in BGRA8 format.
我试图识别Gray32Float - > RGB pixelformat转换以补偿UWP中缺少的支持,并使用WPF示例中的公式生成此代码:
I tried to identify the Gray32Float -> RGB pixelformat conversion to compensate for the lack of support in UWP and came out with this code which uses the formula from the WPF sample:
public static unsafe void PseudoColorFor16BitInfrared(int pixelWidth, byte* inputRowBytes, byte* outputRowBytes)
{
ushort* inputRow = (ushort*)inputRowBytes;
uint* outputRow = (uint*)outputRowBytes;
for (int x = 0; x < pixelWidth; x++)
{
//outputRow[x] = InfraredColor(inputRow[x] / (float)ushort.MaxValue);
// algorithm from Kinect 2 SDK - InfraredBasics-WPF sample
const float InfraredSourceValueMaximum = ushort.MaxValue;
const float InfraredSourceScale = 0.75f;
const float InfraredOutputValueMaximum = 1f;
const float InfraredOutputValueMinimum = 0.01f;
var infraValue = Math.Min(InfraredOutputValueMaximum, (((float)inputRow[x] / InfraredSourceValueMaximum * InfraredSourceScale) * (1.0f - InfraredOutputValueMinimum)) + InfraredOutputValueMinimum);
// UWP does not support BitmapPixelFormat Gray32Float at all - we need to convert value to BGRA8 BitmapPixelFormat to display it
uint scRgbVal = (uint)(0xff * Math.Sqrt(infraValue));
outputRow[x] = (0x00010101 * scRgbVal) | 0xff000000;
}
}
结果不尽相同,但接近SDK输出的红外样本。
如果您想知道代码片段中的Sqrt是什么,请检查以下链接:
Gray32Float 跨度>&NBSP;&NBSP;&NBSP;&NBSP;
Result is not identical but close to what the Infrared sample from the SDK outputs.
if you are wondering what for is the Sqrt in the code snippet, then check this link: Gray32Float
这篇关于获得没有颜色的红外线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!