Issues with Image Orientation Handling in AR App (MediaPipe + YOLO on Android)

33 views
Skip to first unread message

Varun S

unread,
Feb 13, 2025, 1:57:32 AMFeb 13
to MediaPipe

Hi everyone,

I'm working on an AR application using the MediaPipe plugin for image processing and a custom YOLO model for object detection. Everything works fine in the Unity Editor Game View, but when I build it for Android, I face orientation issues.

Here’s how I’m setting up my WebCamTexture using MediaPipe:

private void SetupWebcam()
{
    // Instead of getting a WebCamTexture from a WebCamSource,
    // rely entirely on the ImageSource.
    var imageSource = ImageSourceProvider.ImageSource;
    if (imageSource == null)
    {
        Debug.LogError("[RunYOLO9n] No valid ImageSource found!");
        return;
    }

    // Optionally, if you need to prime any texture frame, do it here.
    // For example, you might want to do an initial read:
    var tex = imageSource.GetCurrentTexture();
    if (tex == null)
    {
        Debug.LogWarning("[RunYOLO9n] The current texture is not yet available.");
    }
    else
    {
        Debug.Log("[RunYOLO9n] Using current texture from ImageSource.");
    }
}

The Issue:
  • When I run the app on Android, the log prints the rotation as 270 degrees. The log also states that the device is in portrait mode, but the detection only works correctly in Landscape Left.

    Is there a proper way to handle this rotation automatically in Unity (without manually adjusting bounding boxes)?
    How can I ensure the app works properly in both Portrait and Landscape orientations?
    Any insights or suggestions would be greatly appreciated! Thanks in advance.

Reply all
Reply to author
Forward
0 new messages