Sorry for that. Ok, Iām using the QRCode 0.3a by Daniel Shiffman and [Zxing For Processing (barcode library)]
[Rolf van Gelder] examples. Iām using processing 3.4
The code for the QRcode example is:
/*
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;
}
}
The barcode reader cam from the zxing library is:
/*****************************************************************************
*
* barcodeReaderCam - v07/26/2018
*
* An example of the use of the ZXING4P.barcodeReader() method.
*
* Opens a webcam and tries to find barcodes in the image.
*
* You can define for which barcode types it will scan.
* Per default it looks for all available types.
*
* When a barcode is detected it will display the decoded text.
*
* Run this sketch and hold a printed copy of a barcode in front of the cam.
*
* Note: make sure your video image is NOT mirrored! It won't detect QRCodes
* that way...
*
* Library page:
* http://cagewebdev.com/zxing4processing-processing-library/
*
* (c) 2013-2018 Rolf van Gelder, http://cagewebdev.com, http://rvg.cage.nl
*
*****************************************************************************/
// IMPORT THE ZXING4PROCESSING LIBRARY AND DECLARE A ZXING4P OBJECT
import com.cage.zxing4p3.*;
ZXING4P zxing4p;
// PROCESSING VIDEO LIBRARY
import processing.video.*;
Capture video;
// PIMAGE WITH THE BARCODES TO DETECT
PImage scanArea;
// TEXT THAT WAS FOUND
String decodedText;
String latestDecodedText = "";
// FORMAT OF THE LATEST FOUND BARCODE
String barcodeFormat = "";
int txtWidth;
// FOR THE VIEW FINDER AND SCAN AREA
int frameWidth = 240;
int frameHeight = 260;
int lineSize = 40;
// CORNERS OF THE VIEW FINDER
PVector ul, ur, ll, lr;
// LIST WITH BARCODE TYPES TO LOOK FOR
ArrayList<String> barcodeTypes = new ArrayList<String>();
/*****************************************************************************
*
* SETUP
*
*****************************************************************************/
void setup() {
size(640, 480);
// LAYOUT
textAlign(CENTER);
textSize(30);
// CREATE CAPTURE
video = new Capture(this, width, height);
// START CAPTURING
video.start();
// CREATE A NEW EN-/DECODER INSTANCE
zxing4p = new ZXING4P();
// DISPLAY VERSION INFORMATION
zxing4p.version();
// UPPER LEFT CORNER OF THE VIEW FINDER
ul = new PVector((width - frameWidth) >> 1, (height - frameHeight) >> 1);
// UPPER RIGHT CORNER OF THE VIEW FINDER
ur = new PVector(ul.x + frameWidth, ul.y);
// LOWER LEFT CORNER OF THE VIEW FINDER
ll = new PVector(ul.x, ul.y + frameHeight);
// LOWER RIGHT CORNER OF THE VIEW FINDER
lr = new PVector(ur.x, ur.y + frameHeight);
// AREA TO SCAN
scanArea = createImage(frameWidth, frameHeight, RGB);
// BARCODE TYPES THAT WILL BE SCANNED FOR
// SUPPORTED BARCODE TYPES:
// AZTEC
// CODABAR
// CODE_128
// CODE_39
// CODE_93
// DATA_MATRIX
// EAN_13
// EAN_8
// ITF
// MAXICODE
// PDF_417
// QR_CODE
// RSS_14
// RSS_EXPANDED
// UPC_A
// UPC_E
// UPC_EAN_EXTENSION
barcodeTypes.add("EAN_8");
barcodeTypes.add("EAN_13");
barcodeTypes.add("DATA_MATRIX");
barcodeTypes.add("QR_CODE");
} // setup()
/*****************************************************************************
*
* DRAW
*
*****************************************************************************/
void draw() {
background(0);
// UPDATE CAPTURE
if (video.available()) video.read();
// DISPLAY VIDEO CAPTURE
set(0, 0, video);
if (frameCount % 50 == 0) {
// COPY THE VIEW FINDER AREA TO THE SCAN AREA
scanArea.copy(video, (int)ul.x, (int)ul.y, frameWidth, frameHeight, 0, 0, frameWidth, frameHeight);
}
// DISPLAY VIEW FINDER
pushStyle();
noFill();
strokeWeight(4);
stroke(255, 0, 0);
line(ul.x, ul.y, ul.x + lineSize, ul.y);
line(ul.x, ul.y, ul.x, ul.y + lineSize);
line(ur.x - lineSize, ur.y, ur.x, ur.y);
line(ur.x, ur.y, ur.x, ur.y + lineSize);
line(ll.x, ll.y, ll.x + lineSize, ll.y);
line(ll.x, ll.y - lineSize, ll.x, ll.y);
line(lr.x - lineSize, lr.y, lr.x, lr.y);
line(lr.x, lr.y - lineSize, lr.x, lr.y);
popStyle();
// DISPLAY LATEST DECODED TEXT AND FORMAT
if (!latestDecodedText.equals("")) {
pushStyle();
txtWidth = int(textWidth(latestDecodedText + " (" + barcodeFormat + ")"));
fill(0, 150);
rect((width>>1) - (txtWidth>>1) - 5, 15, txtWidth + 10, 36);
fill(255, 255, 0);
text(latestDecodedText + " (" + barcodeFormat + ")", width>>1, 43);
popStyle();
} // if (!latestDecodedText.equals(""))
// TRY TO DETECT AND DECODE A QRCODE IN THE VIDEO CAPTURE
// multiFormatReader(PImage img, boolean tryHarder)
// multiFormatReader(PImage img, boolean tryHarder, ArrayList<String> barcodeTypes)
// img: image to scan for barcodes
// tryHarder: false => fast detection (less accurate)
// true => best detection (little slower)
// barcodeTypes: barcode types to scan for
try {
// SCAN FOR ALL AVAILABLE BARCODE TYPES
//decodedText = zxing4p.barcodeReader(scanArea, false);
// SCAN FOR SPECIFIC BARCODE TYPES
decodedText = zxing4p.barcodeReader(scanArea, false, barcodeTypes);
// GET THE TYPE OF THE LAST SCANNED BARCODE
barcodeFormat = zxing4p.getBarcodeFormat();
}
catch (Exception e) {
// NOT FOUND
decodedText = "";
} // try
if (!decodedText.equals("")) {
// FOUND A BARCODE!
if (latestDecodedText.equals("") || (!latestDecodedText.equals(decodedText))) {
println("Zxing4processing detected: " + decodedText + " (" + barcodeFormat + ")");
}
latestDecodedText = decodedText;
} // if (!decodedText.equals(""))
} // draw()
/*****************************************************************************
*
* KEYBOARD HANDLER
*
*****************************************************************************/
void keyPressed() {
switch(key) {
case ' ':
// RESET
decodedText = "";
latestDecodedText = "";
break;
} // switch
} // keyPressed()
For the QR code example I press the spacebar to snap the image of the QR code from printed as attached below then the error shown. For the barcode example I didnāt press anything and just show any barcode on books and it donāt read them. Iām new to the qr code and bar code processing. I just try them based on what I googled.