QR code recognition is required in'Android'. Is there no workaround?

QR code recognition is required in’Android’. Is there no workaround?

Reference link: QR CODE library for Processing 3.0.2 Windows/Linux/MacOSX/Android.. writeQR() and readQR(). - Processing 2.x and 3.x Forum

When implemented in the above way,

If you link with the actual smartphone cam, that photo should be recognized.
However, that photo is not recognized by the QR code.

Only those fixed images and only accurate images can be interpreted.

Is there any solution? Is there any way to receive and recognize ketai cam photo data?

this should give you camera data.

int w = 1400,h = 580;

PShader edges;
KetaiCamera cam;
float counter;
boolean mdown;

void settings(){

void setup() {
  int n = 2;
  cam = new KetaiCamera(this, 1200*n, (280)*n, 60);

void draw() {
  if (frameCount>100&&!cam.isStarted()){cam.start();}
  image(cam, width/2, height/2);

void onCameraPreviewEvent(){

// start/stop camera preview by tapping the screen
void mousePressed(){
  if (cam.isStarted()){
  }else cam.start();

@GWAK ===
I dont know to do that with Ketai but you can use the android native wy to display the camera data into a surfaceView; after that you have only to use the android mobile vision API and its barcode detector to get the code as a string, which can be passed as an url: tested, it works fine.

1 Like

Via Ketai camera

  1. In recognizing the QR code on the screen of the camera
  2. Fixed image is recognized by QR code,
  3. Real-time video is not recognized.


Hello. Thank you for answer. We would appreciate if you could give us the source code url.
Thank you.

@GWAK === as for video within a surface view you can find on the forum many examples with code i have already given ; as for the barcode detector you can refer to the android API mobile vision importing some packages:

import com.google.android.gms.vision.CameraSource;
import com.google.android.gms.vision.Detector;
import com.google.android.gms.vision.barcode.Barcode;
import com.google.android.gms.vision.barcode.BarcodeDetector;

dont forget permissions for camera
1 Like

Dear akenaton, @akenaton

Thank you for your kind answer.
However, I can’t find your previous posts in the forums.
Please tell me the’url address’ that contains the content of the test.

I can’t find it in the’Forum’. help me.

@GWAK ===
see here: https://discourse.processing.org/t/play-videos-in-my-apps/23707

– of course buttons and sliders are not useful for your app; what is important is the surfaceView (and perhaps the way to load your video)

1 Like


I know what you mean.
However, if you’ve solved it, you share the code, please.
I need a code that recognizes’QR’, not video.

If you have any sample code, please share it.
Thank you.

@GWAK === the barcode dtector from android works with a video and from the video recognizes the barcode

1 Like

Hello, do you need this code? I just fixed the zxing4p library to work on android. If you need it, I can share the project with you.

1 Like



Thank you for sharing. Thank you for your interest.

Hi and good morning!
I prepare an example to share.

1 Like

Hello, here is an example program, the original library that I have used is ZXING4P, I have modified one of the methods used to read QR codes and I have translated it to be compatible with the “android.graphics” framework libraries. Bitmap".

Basically the modification deals with building a Bitmap in android with the data from the PImage and then manually dumping the array of pixels from the PImage into the bitmap, everything that follows the process is the same as in windows and linux.

This also works for the video Stram example out there where it sends live webcam video over the network, with this way of creating a Bitmap on Android you could also use Daniel Shiffman’s library to send live video from the android phone.

It would be great if the creators of these libraries added the compatibility modifications to the libraries officially :wink:

[Dropbox - QRdecoderAndroid.zip - Simplify your life](https://Project example)

1 Like

Hola, ahora mismo estoy trabajando en el port completo de la libreria zxing4processing 2.0.
En esta version la libreria pretende ofrecer todo lo que ofrecia antes mas todas las funcionalidades portadas al sistema operativo Android para nuestro querido Processing 4.x.x.

En cuanto la pueda tener lista la publicare, es una simple actualizacion de la que ya existe que funciona super bien, la libreria no es mia originalmente, yo solo voy a actualizarla para ser compatible con Android :wink:

1 Like


Thanks for sharing the source code.
Thank you sincerely.

Interpretation works really well. (decodeQRPImage)
However, (encodeQRPImage) does not work.

PImage img;
PImage qr_make;
PImage qr_make_copy;
String msg = "zxing4processing library";
void setup() {
   img = loadImage("000.jpg");
   println("DECODED TEXT(1):", decodeQRPImage(img));    
   img = loadImage("001.png");
   println("DECODED TEXT(2):", decodeQRPImage(img));  
   qr_make = encodeQRPImage(msg,800,800);
   qr_make_copy = qr_make.get(0,0,800,800);    
void draw(){
 background(150);  imageMode(CENTER);
 if(qr_make_copy != null){
   println(" qr_make_copy not null");
   println(" qr_make_copy width : "+str(qr_make_copy.width));
   println(" qr_make_copy height : "+str(qr_make_copy.height));   
   image(qr_make,      round(width/2), round(0));
   image(qr_make_copy, round(width/2), round(height/2));
   println(" qr_make_copy null");
DECODED TEXT(1): This is an example of the decodeImage() method
(zxing4processing library)
DECODED TEXT(2): goldstarit
 qr_make_copy not null
 qr_make_copy width : 800
 qr_make_copy height : 800

The image created by qr exists in size. but not marked I don’t know why.

Hola, aqui tienes la libreria portada al completo a Android, puedes hacer correr cualquier ejemplo de la libreria original desde Android con processing sin ningun problema :wink:

Aqui la libreria original para Desktop: CAGE Web Design | zxing4processing - Processing Library - CAGE Web Design
Aqui la libreria portada por mi para Android: ZXING4P Ported to Android mode P4 ;)

Puedes cojer cualquier ejemplo de la original y hacerlo funcionar en Android :wink:

1 Like


I solved the problem.
There is a color problem.I fixed it by editing the above.
It might be useful for reference.

public PImage generateQRCode(String content, int widths, int heights) {
        PImage pImage = new PImage(widths, heights);

        QRCodeWriter encoder = new QRCodeWriter();

        try {
            BitMatrix bitMatrix = encoder.encode(content, BarcodeFormat.QR_CODE, widths, heights);

            for (int i=0; i<widths; i++){
                for (int j=0; j<heights; j++) {
                    color black = color(0);
                    int colorValue = 0; // BLACK
                    if (!bitMatrix.get(j, i)) {colorValue = 16777215;  black = color(255);  }   // WHITE
                    // ADD THE PIXEL TO THE IMAGE
                    // System.out.println(colorValue); 
                    pImage.set(i, j, black);
                } // for(int j=0; j<height; j++)
        catch ( Exception e ) {
            System.out.println("Error generating QRCode image (PImage generateQRCode) " + e);
        } // try

        return pImage;
  1. before modification

pImage.set(i, j, colorValue);

  1. After modification

pImage.set(i, j, black);

It works fine. Thanks to this, it is possible to recognize and create QR codes.
thank you.

1 Like