Hello everybody,
Today, I found the QRCode library from Daniel Shiffman with the following 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;
}
}
But if Ioad it, the 'Capture video' (line 4 here, normally line 17) is underlined red and is says: 'The class 'Capture' does not exist'.
Does anybody knows how to fix this? I'm using Processing 3 by the way.
Is it possible to make this code compatible with Android? If I load this code in Android mode, there are no errors in the PDE, but if I run it, it crashes. How can I fix this?
Regards, Daantje