Multiple QR Code

edited May 2016 in Library Questions

Hello I am a student of Interaction design and use by a few months Processing. I want to design a code which allows to a camera (such as that of the computer) to identify various QR code. Each QR code is connected to a single content (video, photos, augmented reality, etc.). I started from the code written by Tom Igoe and Daniel Shiffman and I wonder if someone can help me complete the code by giving the opportunity to the camera to read various QR Code. Thank you. This is the code:

/*
QRcode reader
 Generate images from a QRcode generator such as
 http://qrcode.kaywa.com/ and put them in this sketch's
 data folder.
 Press spacebar to read from the camera, generate an image,
 and scan for barcodes.  Press f to read from a file and scan.
 Press s for camera settings.
 Created 9 June 2007
 by Tom Igoe / Daniel Shiffman
 */


import processing.video.*;
import qrcodeprocessing.*;

Capture video;                                 // instance of the video capture library
String statusMsg = "Waiting for an image";     // a string to return messages:

// Decoder object from prdecoder library
Decoder decoder;

void setup() {
  size(400, 320);
  video = new Capture(this, 320, 240);
  video.start();

  // Create a decoder object
  decoder = new Decoder(this);
}

// When the decoder object finishes
// this method will be invoked.
void decoderEvent(Decoder decoder) {
  statusMsg = decoder.getDecodedString();
}

void captureEvent(Capture video) {
  video.read();
}

void draw() {
  background(0);

  // Display video
  image(video, 0, 0);
  // Display status
  text(statusMsg, 10, height-4);

  // If we are currently decoding
  if (decoder.decoding()) {
    // Display the image being decoded
    PImage show = decoder.getImage();
    image(show, 0, 0, show.width/4, show.height/4); 
    statusMsg = "Decoding image";
    for (int i = 0; i < (frameCount/2) % 10; i++) statusMsg += ".";
  }
}

void keyReleased() {
  // Depending on which key is hit, do different things:
  switch (key) {
  case ' ':        
    // Spacebar takes a picture and tests it:
    // copy it to the PImage savedFrame:
    PImage savedFrame = createImage(video.width, video.height, RGB);
    savedFrame.copy(video, 0, 0, video.width, video.height, 0, 0, video.width, video.height);
    savedFrame.updatePixels();
    // Decode savedFrame
    decoder.decodeImage(savedFrame);
    break;
  case 'f':    // f runs a test on a file
    PImage preservedFrame = loadImage("qrcode.png");
    // Decode file
    decoder.decodeImage(preservedFrame);
    break;
  }
}

Answers

  • Various or multiple?

    The code you have posted will look for and try to decode one QR code in some image.

    If you want it to decode VARIOUS QR codes, well, what kind of different QR codes are there? I know for a fact that there are several different sizes and styles of QR codes. Presumably the decoder can decode all of them? If not, you may need to use a different library...

    If you want to decode MULTIPLE QR codes in the same image, you might be out of luck unless the QR decoder can give you more information about the QR code it found in an image (maybe the position of it so you can draw over it and retry the decoding to find more QR codes, say), or unless the decoder can accept more input (like how many different QR codes it should be looking for).

    In any case, this is not just something we can code up for you magically - nor will we. Please make an attempt at understanding the example code you have & modifying it for your needs BEFORE asking for help.

Sign In or Register to comment.