Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XRCpuImage Rotation and Clipping Issue Affecting AI Model Application #1188

Open
AntoineChauviere opened this issue Jul 26, 2024 · 1 comment
Labels
how to Explains how to accomplish something

Comments

@AntoineChauviere
Copy link

AntoineChauviere commented Jul 26, 2024

Hello,

I am trying to apply my AI model to an XRCpuImage. It works very well, but I've noticed that the XRCpuImage is rotated by 90 degrees and seems to be clipped. This results in the image I see on my phone not matching the image to which I am applying the AI (XRCpuImage).

I would like to know how to obtain an XRCpuImage that matches what is displayed on the screen. This way, I can correctly perform conversions (such as rescaling, RGB24, etc.) on the correct image before applying the AI.

Here is a snippet of my code where the issue needs to be addressed:

public void ProcessCameraImageAsync(XRCpuImage image)
{
  var conversionParams = new XRCpuImage.ConversionParams
  {
      // Configure the conversion
      inputRect = new RectInt(0, 0, image.width, image.height),
      outputDimensions = new Vector2Int(320, 256),
      outputFormat = TextureFormat.RGB24,
      transformation = XRCpuImage.Transformation.None
  };
  
  // Texture size
  int size = image.GetConvertedDataSize(conversionParams);
  
  // Allocate a buffer for the image data
  var buffer = new NativeArray<byte>(size, Allocator.Persistent);
  
  // Convert the image
  image.Convert(conversionParams, buffer);
  
  // Update the displayed texture with the converted data
  displayTexture.LoadRawTextureData(buffer);
  displayTexture.Apply();
  
  // Access pixel data
  byte[] pixelData = buffer.ToArray();
 };

I need to apply the necessary changes to ensure that the XRCpuImage matches what is displayed on the screen and correct for any clipping issues before proceeding with the conversion and application of the AI model.

Any guidance or suggestions on how to resolve this issue would be greatly appreciated.

Thank you!

@AntoineChauviere AntoineChauviere added the how to Explains how to accomplish something label Jul 26, 2024
@tdmowrer
Copy link
Contributor

The comment in the Depth Images sample explains why this is, and provides some pointers on how to convert between the raw and displayed images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
how to Explains how to accomplish something
Projects
None yet
Development

No branches or pull requests

2 participants