"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Get 2D Texture from AR Camera

Hello guys, Im trying to build a small Image identification Project following this guy's steps. He's using a script where he calls from a method that return a cropped texture from the active camera (which in this case is not AR) and returns it in a 32 bits color format, and classifies the texture everytime the pixels are updated.

 

This is the part of the code that I want to do but with AR Camera:

 

public class CameraImage : MonoBehaviour {

       WebCamTexture webcamTexture;     RawImage image;

    void Start() {         //delay initialize camera         webcamTexture = new WebCamTexture();         image = GetComponent<RawImage>();         image.texture = webcamTexture;         webcamTexture.Play();     }

    public Color32[] ProcessImage(){         //crop         var cropped = TextureTools.CropTexture(webcamTexture);         //scale         var scaled = TextureTools.scaled(cropped, 112, 112, FilterMode.Bilinear);         //run detection         return scaled.GetPixels32();     } }

Someone then said to try the "CopyToTexture" method from Image but its not working... I am sorry if this question is quite basic but I'm still not very familiar with the whole Vuforia structure and capabilities.

Thank you so much for helping me out, If you find any helpful tutorial guide for this kind of things, pleave leave it in here as I'd love to know more about it!

(PS: Is there a way to put the code above in a more proper format in this forum? Tried using the general code tag but didnt work)

Take a look here:  https://library.vuforia.com/content/vuforia-library/en/articles/Solution/Working-with-the-Camera.html#How-To-Access-the-Camera-Image-in-Unity

 

I just tried that approach but for some unknown reason Vuforia.Image image = CameraDevice.Instance.GetCameraImage(mPixelFormat); is always null aka never available, even though the Frame Format was previously set to the corresponding pixel format.

You attached the full script (the second part) to a gameobject and it didnt work?  I made a blank scene, added an ARCamera and added the script and I'm seeing image pixel log data on both webcam (editor) and device.