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());
}
}
I solved just saving IR and Depth images in their own format, without the DepthToColor transformation, end then reconstructing the Capture using them.