0

我正在使用 Kinect DK,我正在尝试保存相机捕获(带有颜色、深度、红外图像的单帧)。我已经意识到要保存 Capture 对象,我必须保存 3 个单张图像(上面引用),而不是从保存的文件中重建 Capture。我已经成功保存了彩色图像,但是由于它们的格式,我在深度和红外方面遇到了一些问题。当我尝试创建我认为有必要使用其函数 a.DepthImageToColorCamera(capture.Depth, depthImage) 返回具有指定深度图像对象尺寸的图像时,会出现问题。系统返回 <Microsoft.Azure.Kinect.Sensor.AzureKinectException: 'Pixels not aligned to stride of each line'> 异常。有人有同样的问题吗?谢谢。

PS 我会给你微软文档的链接https://docs.microsoft.com/it-it/azure/kinect-dk/use-image-transformation

            string pathDepth = @"C:\Users\MINALE\Desktop\Kinect_app\depth.json";

            if (!File.Exists(pathDepth))
            {
                // Create a file to write to.
                using (StreamWriter sw = File.CreateText(pathDepth))
                {
                    JsonSerializer serializer = new JsonSerializer { Formatting = Formatting.Indented };

                    Image depthImage = new Image(ImageFormat.Depth16, 512, 512);

                    try
                    {
                        var a = calibration.CreateTransformation();
                        a.DepthImageToColorCamera(capture.Depth, depthImage);
                    }
                    catch (Exception ex)
                    {

                    }

                    serializer.Serialize(sw, depthImage.GetPixels<BGRA>().Span.ToArray());

                }

            }
4

0 回答 0