We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm using the following script to extract multiple QR codes from my webcam:
The code runs fine and detects multiple QR codes on my regular lenovo laptop webcam. However, for some reason, when I utilize an external microsoft lifecam hd-3000, the program just recognizes one QR code at a time (hence I have to have just one QR code on the screen for it to be recognized).
Would you happen to have heard of such a bizarre issue? Your feedback is much appreciated
import diewald_bardcode.*;
import diewald_bardcode.CONSTANTS.*;
import codeanticode.gsvideo.*;
GSCapture cam;
int cam_size_x = 640;// 1280;//1280;//800; //1280;
int cam_size_y = 480;// 720;//800;//600; //(int)(3.0*cam_size_x/4.0);
PFont font;
// SETUP
// ——————————————————————————————————–
void setup()
{
font = createFont("Arial", 20);
textFont(font);
size(cam_size_x, cam_size_y);
String[] cameras = GSCapture.list();
cam = new GSCapture(this, 640, 480,30); // …, cam_size_y, cameras[1] ) <– If multiple Cameras are used!
cam.start();
// uncomment this to see your supported Camera Resolutions!
// println ("Supported Resolution:");
// int[][] res = cam.resolutions();
// for (int i = 0; i < res.length; i++) {
// println(res[i][0] + "x" + res[i][1]);
// }
}
// DRAW
// ——————————————————————————————————–
void draw()
{
if ( cam.available() ) {
background(0);
cam.read();
cam.loadPixels();
image(cam, 0, 0);
decode();
}
}
// Decode QR Code
// ——————————————————————————————————–
void decode() {
DecodingResult[] dr = Barcode.decodeMultiQRcode(cam, CHARACTER_SET.DEFAULT, true); //true = tryHarder (slower)
for (int QR_count = 0; QR_count < dr.length; QR_count++) {
if ( dr[QR_count].decodingFailed() == true) {
fill(255, 0, 0);
text( "No decoding information could be found!", 20, 40 );
}
else {
fill (0, 255, 0);
int xpos = int(dr[QR_count].getCorners()[0].x);
int ypos = int(dr[QR_count].getCorners()[0].y);
text(dr[QR_count].getText(), xpos, ypos);
for (int PosIndex = 0; PosIndex < 3; PosIndex++) {
int NewX = int(dr[QR_count].getCorners()[PosIndex].x);
int NewY = int(dr[QR_count].getCorners()[PosIndex].y);
pushMatrix();
translate(NewX-10, NewY-10);
rect(0, 0, 20, 20);
popMatrix();
}
}
}
}
Answers
Why don't you enqueue all of the the PImage objects in a List?
Then deal w/ them in a more appropriate time! (%)
thank you for your prompt response,
It would be great if you can provide me a code to do that, because i am having trouble with the above library to convert from capture to PImage and then to the Decode function.
thank you
I believe GSCapture should be a subclass of PImage. Otherwise you wouldn't be able to directly use it as an image() argument!
BtW, plz highlight your posted code and hit CTRL+K in order to properly format it! :-\"
I've just tried the following alteration to no avail. Any more suggestions? Thanks!
I've meant a List of PImage objects! (~~)
Hey thank you for your quick response. I just tried the following (again, same result ):
Cool emoticons btw :P