Log in or register to post comments

Error on Image.PIXEL_FORMAT

June 10, 2019 - 6:08am #1

Unity 2019.1.5f1 with Vuforia

Trying To Access the Camera Image in Unity using 

CameraDevice.Instance.SetFrameFormat(Image.PIXEL_FORMAT.RGB888, true);

but have error "error CS0426: The type name 'PIXEL_FORMAT' does not exist in the type 'Image'"

i try   Vuforia.Image.PIXEL_FORMAT mPixelFormat = Vuforia.Image.PIXEL_FORMAT.RGB888;

but have same error.

 

what i am doing wrong?

AttachmentSize
Image icon 2019-06-10_16-04-20.png9.28 KB
Image icon 2019-06-10_16-14-15.png9.12 KB

Error on Image.PIXEL_FORMAT

September 4, 2019 - 6:42am #5

I encoutered the same problem after upgrading a Vuforia.project and it's easy to fix. Image.PIXEL_FORMAT moved now to Vuforia.PIXEL_FORMAT. Just remove the Image and it will be fine (s.b.)

public class VuforiaImageAccess : MonoBehaviour
{
    public event EventHandler<Image> ImageReceived;

    public CameraDeviceMode CameraMode = CameraDeviceMode.MODE_OPTIMIZE_SPEED;

    private PIXEL_FORMAT mPixelFormat = PIXEL_FORMAT.UNKNOWN_FORMAT;
   ...
}

Error on Image.PIXEL_FORMAT

June 24, 2019 - 2:49am #4

Instead of Image.PIXEL_FORMAT, delete Image or something like this: PIXEL_FORMAT

using UnityEngine;

using System.Collections;

using Vuforia;

public class CameraImageAccess : MonoBehaviour

{

    #region PRIVATE_MEMBERS

    

    private PIXEL_FORMAT mPixelFormat = PIXEL_FORMAT.UNKNOWN_FORMAT;

    private bool mAccessCameraImage = true;

    private bool mFormatRegistered = false;

    #endregion // PRIVATE_MEMBERS

    #region MONOBEHAVIOUR_METHODS

    void Start()

    {

#if UNITY_EDITOR

        mPixelFormat = PIXEL_FORMAT.GRAYSCALE; // Need Grayscale for Editor

#else

        mPixelFormat = Image.PIXEL_FORMAT.RGB888; // Use RGB888 for mobile

#endif

        // Register Vuforia life-cycle callbacks:

        VuforiaARController.Instance.RegisterVuforiaStartedCallback(OnVuforiaStarted);

        VuforiaARController.Instance.RegisterTrackablesUpdatedCallback(OnTrackablesUpdated);

        VuforiaARController.Instance.RegisterOnPauseCallback(OnPause);

    }

    #endregion // MONOBEHAVIOUR_METHODS

    #region PRIVATE_METHODS

    void OnVuforiaStarted()

    {



        // Try register camera image format

        if (CameraDevice.Instance.SetFrameFormat(mPixelFormat, true))

        {

            Debug.Log("Successfully registered pixel format " + mPixelFormat.ToString());

            mFormatRegistered = true;

        }

        else

        {

            Debug.LogError(

                "\nFailed to register pixel format: " + mPixelFormat.ToString() +

                "\nThe format may be unsupported by your device." +

                "\nConsider using a different pixel format.\n");

            mFormatRegistered = false;

        }

    }

    /// <summary>

    /// Called each time the Vuforia state is updated

    /// </summary>

    void OnTrackablesUpdated()

    {

        if (mFormatRegistered)

        {

            if (mAccessCameraImage)

            {

                Vuforia.Image image = CameraDevice.Instance.GetCameraImage(mPixelFormat);

                if (image != null)

                {

                    Debug.Log(

                        "\nImage Format: " + image.PixelFormat +

                        "\nImage Size:   " + image.Width + "x" + image.Height +

                        "\nBuffer Size:  " + image.BufferWidth + "x" + image.BufferHeight +

                        "\nImage Stride: " + image.Stride + "\n"

                    );

                    byte[] pixels = image.Pixels;

                    if (pixels != null && pixels.Length > 0)

                    {

                        Debug.Log(

                            "\nImage pixels: " +

                            pixels[0] + ", " +

                            pixels[1] + ", " +

                            pixels[2] + ", ...\n"

                        );

                    }

                }

            }

        }

    }

    /// <summary>

    /// Called when app is paused / resumed

    /// </summary>

    void OnPause(bool paused)

    {

        if (paused)

        {

            Debug.Log("App was paused");

            UnregisterFormat();

        }

        else

        {

            Debug.Log("App was resumed");

            RegisterFormat();

        }

    }

    /// <summary>

    /// Register the camera pixel format

    /// </summary>

    void RegisterFormat()

    {

        if (CameraDevice.Instance.SetFrameFormat(mPixelFormat, true))

        {

            Debug.Log("Successfully registered camera pixel format " + mPixelFormat.ToString());

            mFormatRegistered = true;

        }

        else

        {

            Debug.LogError("Failed to register camera pixel format " + mPixelFormat.ToString());

            mFormatRegistered = false;

        }

    }

    /// <summary>

    /// Unregister the camera pixel format (e.g. call this when app is paused)

    /// </summary>

    void UnregisterFormat()

    {

        Debug.Log("Unregistering camera pixel format " + mPixelFormat.ToString());

        CameraDevice.Instance.SetFrameFormat(mPixelFormat, false);

        mFormatRegistered = false;

    }

    #endregion //PRIVATE_METHODS

}

Error on Image.PIXEL_FORMAT

June 15, 2019 - 4:58am #3

HELLO, i HAVE THE SAME PROBLEM.

AttachmentSize
Image icon ERROR_VUFORIA+.PNG16.49 KB

Error on Image.PIXEL_FORMAT

June 10, 2019 - 3:00pm #2

Hello,

Here's an article that may help: https://library.vuforia.com/articles/Solution/Working-with-the-Camera#How-To-Obtain-HD-Camera-Frames

Thanks,

Vuforia Engine Support

Log in or register to post comments