-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProQRessing.pde
80 lines (66 loc) · 2.01 KB
/
ProQRessing.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
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, 640, 480);
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;
}
}