Log in or register to post comments

QR-Code with Vuforia

October 30, 2014 - 9:45am #12

Hi, I'm a newbie. 

I installed vuforia in eclipse and now I want to  to recognize qr code without using Unity.


How can I do?



QR-Code with Vuforia

November 2, 2014 - 12:21pm #11

no one knows how to help me?

QR-Code with Vuforia

November 3, 2014 - 12:25am #10

Hi, i have do that using a pair of libraries depending of the SO....

For Android i use zxing is opensource, there are a function onQcarUpdate where you can get the image from the camera, and then pass it to the zxing decoder object.

For iOS is the same, but using a different library to decode the QR, i use Zbar for it.

QR-Code with Vuforia

November 4, 2014 - 1:30am #9

Hi jmpslo 

I use Android,  have you  an example where I can get ideas?


Thanks a lot

QR-Code with Vuforia

November 4, 2014 - 1:49am #8

I have a android project with the zxing code, and compiled as a library, and then i added the library to my AR project.

Then i use that code.



That is my code on qcarupdate, altough i have a counter to avoid send all frames...

             Image imageGRAYSCALE = null;
            Frame frame = state.getFrame();
            for (int i = 0; i < frame.getNumImages(); ++i) {
                Image image = frame.getImage(i);
                if (image.getFormat() == PIXEL_FORMAT.GRAYSCALE) {
                    imageGRAYSCALE = image;
            if (imageGRAYSCALE != null) {



The function to analyze:


public void analyzeQRImage(Image imageGRAYSCALE){
             ByteBuffer pixels = imageGRAYSCALE.getPixels();
            int imageWidth = imageGRAYSCALE.getWidth();
            int imageHeight = imageGRAYSCALE.getHeight();
            //int stride = imageGRAYSCALE.getStride();

            int dstLeft, dstTop, dstWidth, dstHeight;

            dstLeft = 0;
            dstTop = 0;
            dstWidth = imageWidth;
            dstHeight = imageHeight;
            byte[] data = new byte[pixels.remaining()];
            final PlanarYUVLuminanceSource source = new PlanarYUVLuminanceSource(
                    data, imageWidth, imageHeight, dstLeft, dstTop, dstWidth,
            // output a preview image of the picture taken by the camera
//            final Bitmap previewImage = source.renderCroppedGreyscaleBitmap();
            // set this one as the source to decode
            final BinaryBitmap bitmap = new BinaryBitmap(
                    new HybridBinarizer(source));
            new DecodeImageTask().execute(bitmap);
/*            Log.e("Image", "Image width: " + imageWidth);
            Log.e("Image", "Image height: " + imageHeight);
            Log.e("Image", "Image stride: " + stride);*/     



and the async code

            String decodedText = null;
            final Reader reader = new QRCodeReader();
            try {
                final Result result = reader.decode(bitmap[0], hints);
                decodedText = result.getText();
                //Toast.makeText(VideoPlayback.this, "doInBackground "+decodedText, Toast.LENGTH_SHORT).show();
                if(RAActivity.qrSearch == true){
            } catch (Exception e) {
                decodedText = e.toString();
                // txtScanResult.setText(e.toString());
            return decodedText;


Hope it helps.


QR-Code with Vuforia

November 4, 2014 - 2:06am #7

Thanks, now I will do the tests even if I did not clear some things

QR-Code with Vuforia

November 4, 2014 - 2:19am #6

A little pair of explanations:

Once you have the zxing library working:

1. In the RA activity, you have a function qcarUpdate,

Frame frame = state.getFrame(); // is the code from vuforia to obtain the camera image, that gives you the frame in different formats, and i use only the grayscale image.

Then i have another class to avoid mix the code, it is called QRReaderInstance

That class have a function called analyzeQRImage with the code, that converts the image (of type image) in a BinaryBitmap passing to a PlanarYUVLuminanceSource and converting it to a BinaryBitmap(dont know why, i only copy paste samples until it work), i think PlanarYUVLuminanceSource and BinaryBitmap are subclasses of the zxing library.

Once converted into a BinaryBitmap, an async function is called with new DecodeImageTask().execute(bitmap); (thats on my class QRReaderInstance), and i only copied you the code of doInBackground.

final Reader reader = new QRCodeReader(); thats also as a class of zxing library, i create the object,

final Result result = reader.decode(bitmap[0], hints);  decode the bitmap
decodedText = result.getText(); // and that returns a result (empty if cant read a code


Dont have to do in a async function but i think that is better for performance.


QR-Code with Vuforia

November 4, 2014 - 8:59am #5

Thanks jmpslo ,

I just started studying Vuforia, my goal is to detect and decode the qr code with Android app.

I am now studying the examples of Vuforia, for my purpose I have to use the Image Target, that's right?

QR-Code with Vuforia

November 4, 2014 - 9:18am #4

In fact it works with any samples... That only takes the stream from camera, get the frame and send to decode the image to a qrdecoder...

Almost, the easier sample to learn, i think is the image target, but the same code must work with videoplayback sample or multitarget, or the text reco target...

QR-Code with Vuforia

November 5, 2014 - 7:59am #3

Can you post the structure of the program?


If I understand correctly, I can use the sample of Image Target and then use:

- function qcarupdate

- function analyzeQRImage


- function async code


for take the stream from camera, get the frame and send to decode the image to a qrdecoder.



QR-Code with Vuforia

November 5, 2014 - 10:00am #2

Its complex to post because i have a big framework so far than vuforia samples.

But the basics are that...

onqcarupdate is a callback from the vuforia api, thats on de activity that generate the opengl renderer and put in its view (imageTargets.java). And the code is for get the frame of the camera.

Then with that frame you need to convert to a valid BinaryBitmap, i do that in the function analyzeQRImage, and then pass it to a qrreder instance (from the api of xzing).

Because the decode is expensive, i take out the pass of the image to the qrreader instance from analyzeQRImage function and put in an asyncronous function... so the qrreader instance try to decode the image in other thread than the view.

QR-Code with Vuforia

February 20, 2015 - 2:10am #1

Hi jmpslo, 

                   I'm relatively new to android,let alone vuforia. I would really like some guidance in integrating the qr scanner with the videoplayback sample. I'm really confused as to what the RAActivity and hints are in your code. I would be really grateful if you could point me in the right direction.

Thank you.

Log in or register to post comments