Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

VUFORIA Device.Instance.Get Camera Image (PixelFormat) always returns Image pixels: 0,0,0,...

Discussion in 'Formats & External Tools' started by aesparza, Mar 3, 2017.

  1. aesparza

    aesparza

    Joined:
    Apr 4, 2016
    Posts:
    29
    Hi!

    I would like to obtain from VUFORIA ARCamera frame a texture2D.
    I can do it on UnityEditor.
    But, if I try it on Android, the method returns always an empty image.
    How can I solve this?
    The chosen pixelFormat is supported by the device.

    Thank you all!
     
  2. kedarpethe37

    kedarpethe37

    Joined:
    Jun 1, 2018
    Posts:
    1
    For Android and IPhone , C# script:-

    Code (CSharp):
    1. if (CameraDevice.Instance.SetFrameFormat(Image.PIXEL_FORMAT.RGB888, true)) {
    2. Debug.Log("Successfully registered pixel format " + mPixelFormat.ToString()); }
    3. else  {
    4. Debug.LogError("\nFailed to register pixel format: " + mPixelFormat.ToString() + "\nThe format may be unsupported by your device." + "\nConsider using a different pixel format.\n");
    5. return;
    6. }
    7.  
    8. Image image = CameraDevice.Instance.GetCameraImage(Image.PIXEL_FORMAT.RGB888);
     
  3. iLyxa3D

    iLyxa3D

    Joined:
    Sep 25, 2013
    Posts:
    31
    Try to do it in the next frame using Coroutine. Vuforia scripts examples works only in theory in clear proejects, not in real situation.. So make slow and safe code
     
    Fenikkel likes this.
  4. Fenikkel

    Fenikkel

    Joined:
    Sep 24, 2019
    Posts:
    20
    He is right. I was receiving a null because I was calling CameraDevice.Instance.GetCameraImage in the firs Update frame.

    Thank you mate