0

I'm using the Kinect DK and I'm trying to save the camera Capture (a single frame with Color, Depth, IR images). I've already realised that to save a Capture object I have to save the 3 single images (cited above) and than to reconstruct the Capture from the saved files. I've successfully saved the Color image, but I'm having some issues with Depth and IR, because of their format. The problem occurs when I try to create the var a = calibration.CreateTransformation() which I think is necessary to use its function a.DepthImageToColorCamera(capture.Depth, depthImage) to return an image with the specified dimensions of depthImage object. The system returns a <Microsoft.Azure.Kinect.Sensor.AzureKinectException: 'Pixels not aligned to stride of each line'> exception. Have someone had the same issue? Thanks.

P.S. I'll give you the link to microsoft documentation https://learn.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());

                }

            }
  • Relates with: https://github.com/microsoft/Azure-Kinect-Sensor-SDK/issues/1719 – asergaz Jan 07 '22 at 19:11
  • Suggest that you take a look at the Sensor SDK source code – specifically the [k4arcorder tool](https://github.com/microsoft/Azure-Kinect-Sensor-SDK/tree/develop/tools/k4arecorder). – asergaz Jan 11 '22 at 07:51
  • 1
    I solved just saving IR and Depth images in their own format, without the DepthToColor transformation, end then reconstructing the Capture using them. – Alessandro Minerba May 23 '22 at 07:33
  • You can post the comment as the answer to your own question :)! – asergaz May 26 '22 at 13:37

1 Answers1

0

I solved just saving IR and Depth images in their own format, without the DepthToColor transformation, end then reconstructing the Capture using them.