How to setup ZXing?

Hi,
I want to use the ZXing libarys to detected Qr codes from a mobile camera. The problem is, that I cant get ZXing to accept the WebCamTexture. My current setup gives me an Array out of bounds exception at CalculateLuminanceRGB24. Does anybody previously worked with ZXing and can show me how to set this up?
Any Help will be appreciated.

IntPtr pointer = webCamTex.GetNativeTexturePtr();
        texture2d.UpdateExternalTexture(pointer);
        Result result = multiFormatReader.decode(new BinaryBitmap( new HybridBinarizer( new RGBLuminanceSource(texture2d.EncodeToPNG(),texture2d.width-1,texture2d.height-1))));

Hi @Oribow . This hack:

texture2D.UpdateExternalTexture(webCamTexture.GetNativeTexturePtr());
texture2D.EncodeToPNG();

Won’t work at all. You must copy the webcam’s data to the texture2D like so:

texture2D.SetPixels32(webCamTexture.GetPixels32());
texture2D.Apply()

then send it to ZXing. But here is a much better alternative.

Check out NatCam. It eliminates the need for ZXing’s slow performance on iOS and Android. It supports 8 different barcode formats.

2 Likes

Does NatCam still support barcodes

Not anymore. We deprecated this functionality a few releases ago as we wanted to slim down the API to just camera control.

@Lanre I appreciate your input. After 3 years of waiting someone has finally answered my question. Nice callback to my beginner years as a programmer. :wink:

Lol that’s quite a while. What do you work on now?