Log in or register to post comments

Get 2D Texture from AR Camera

October 11, 2018 - 7:41am #1

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)

Get 2D Texture from AR Camera

October 12, 2018 - 1:16pm #5

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.  If that doesnt work, let us know version numbers of everything you got going.

 

Get 2D Texture from AR Camera

October 12, 2018 - 5:10am #4

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. Trying to investigate on it but it's kind of shady for me.

Get 2D Texture from AR Camera

October 12, 2018 - 12:46am #3

Thanks, will do.

Get 2D Texture from AR Camera

October 11, 2018 - 10:21am #2
Log in or register to post comments