How to get camera frames

I am building a QR code reader using zxing.net, and I want to access the latest camera frame from inside a coroutine. How to access the camera frames.
Also, Can we test the camera part in the emulator that comes with nrsdk.
Example code snippets are appreciated.

Access RGB Camera - NRSDK (gitbook.io)

Not sure about the emulator thoughā€¦ I think the challenge there would be the camera pose would not be relative to the images. You could create a ā€œpretendā€ camera using the WebcamTexture instead, and have that be used in the designerā€¦

Hey, did the code I sent in the PM not work? It doesnā€™t read a QR code in the emulator, but it definitely does when built to the glasses, as itā€™s exactly what I use.

Set a private variable
private NRRGBCamTexture RGBCamTexture { get; set; }

I had a bool and a function to activate and de-active the QR code scanner, but hereā€™s how to get the cam texture

RGBCamTexture = new NRRGBCamTexture();
RGBCamTexture.Play();

Then in update I used the bool I set to activate/deactivate the scanner, and if I was allowed to scan, I cased a few strings that the different QR codes contained from ā€˜resultā€™, but obviously you can do whatever you like and is needed here, this is just an example.

IBarcodeReader barcodeReader = new BarcodeReader();

var result = barcodeReader.Decode(this.RGBCamTexture.GetTexture().GetPixels32(), this.RGBCamTexture.Width, this.RGBCamTexture.Height);
      
            if (result != null)
            {
                // QRCode detected
            }
            else
            {
               // QRCode not detected
            }
        }

1 Like

HI, Iā€™d like to achive something similas. Is this all the code needed? Could you send me the code you sent in the PM? it will be much appreciate it.

Thanks

Hi, yes thatā€™s the same code above as in the PM. Itā€™s really simple. Iā€™ve used it on the Lights/Dev Kit and also on the Ultras, but changing RGBCam to WebCamTexture in order to use the phones camera to scan the QR codes since the Ultras donā€™t have a camera you can access.

The only thing I do different is move IBarcodeReader barcodeReader = new BarcodeReader(); to a function where I activate the scanner instead of being in Update.

Thanks, Iā€™ll let you know if I make it work