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
}
}
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