Skip to content

Commit f63ecf1

Browse files
committed
Updates for video capture examples, new keywords.txt
1 parent 83561d1 commit f63ecf1

16 files changed

Lines changed: 122 additions & 58 deletions

File tree

java/keywords.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ parseXML FUNCTION1 parseXML_
526526
perspective FUNCTION1 perspective_
527527
PFont KEYWORD5 PFont
528528
list FUNCTION1 PFont_list_
529-
PGraphics FUNCTION1 PGraphics_
529+
PGraphics KEYWORD5 PGraphics
530530
beginDraw FUNCTION2 PGraphics_beginDraw_
531531
endDraw FUNCTION2 PGraphics_endDraw_
532532
PI LITERAL2 PI

java/libraries/video/examples/Capture/AsciiVideo/AsciiVideo.pde

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ float fontSize = 1.5;
2929
void setup() {
3030
size(640, 480, P2D);
3131

32-
// Uses the default video input, see the reference if this causes an error
32+
// This the default video input, see the GettingStartedCapture
33+
// example if it creates an error
3334
video = new Capture(this, 160, 120);
35+
36+
// Start capturing the images from the camera
3437
video.start();
38+
3539
int count = video.width * video.height;
36-
println(count);
40+
//println(count);
3741

3842
font = loadFont("UniversLTStd-Light-48.vlw");
3943

java/libraries/video/examples/Capture/BackgroundSubtraction/BackgroundSubtraction.pde

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@ Capture video;
1515

1616
void setup() {
1717
size(640, 480, P2D);
18-
// Uses the default video input, see the reference if this causes an error
18+
19+
// This the default video input, see the GettingStartedCapture
20+
// example if it creates an error
21+
video = new Capture(this, 160, 120);
1922
video = new Capture(this, width, height);
23+
24+
// Start capturing the images from the camera
2025
video.start();
26+
2127
numPixels = video.width * video.height;
2228
// Create array to store the background image
2329
backgroundPixels = new int[numPixels];
@@ -36,11 +42,11 @@ void draw() {
3642
// of the background in that spot
3743
color currColor = video.pixels[i];
3844
color bkgdColor = backgroundPixels[i];
39-
// Extract the red, green, and blue components of the current pixels color
45+
// Extract the red, green, and blue components of the current pixel's color
4046
int currR = (currColor >> 16) & 0xFF;
4147
int currG = (currColor >> 8) & 0xFF;
4248
int currB = currColor & 0xFF;
43-
// Extract the red, green, and blue components of the background pixels color
49+
// Extract the red, green, and blue components of the background pixel's color
4450
int bkgdR = (bkgdColor >> 16) & 0xFF;
4551
int bkgdG = (bkgdColor >> 8) & 0xFF;
4652
int bkgdB = bkgdColor & 0xFF;
@@ -61,7 +67,7 @@ void draw() {
6167
}
6268

6369
// When a key is pressed, capture the background image into the backgroundPixels
64-
// buffer, by copying each of the current frames pixels into it.
70+
// buffer, by copying each of the current frame's pixels into it.
6571
void keyPressed() {
6672
video.loadPixels();
6773
arraycopy(video.pixels, backgroundPixels);

java/libraries/video/examples/Capture/BrightnessThresholding/BrightnessThresholding.pde

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@ Capture video;
1717
void setup() {
1818
size(640, 480, P2D); // Change size to 320 x 240 if too slow at 640 x 480
1919
strokeWeight(5);
20-
// Uses the default video input, see the reference if this causes an error
20+
21+
// This the default video input, see the GettingStartedCapture
22+
// example if it creates an error
2123
video = new Capture(this, width, height);
22-
video.start();
24+
25+
// Start capturing the images from the camera
26+
video.start();
27+
2328
numPixels = video.width * video.height;
2429
noCursor();
2530
smooth();

java/libraries/video/examples/Capture/ColorSorting/ColorSorting.pde

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ int[] bright;
1919
// How many pixels to skip in either direction
2020
int increment = 5;
2121

22-
2322
void setup() {
2423
size(800, 600, P2D);
25-
26-
noCursor();
27-
// Uses the default video input, see the reference if this causes an error
24+
25+
// This the default video input, see the GettingStartedCapture
26+
// example if it creates an error
2827
video = new Capture(this, 160, 120);
28+
29+
// Start capturing the images from the camera
2930
video.start();
3031

3132
int count = (video.width * video.height) / (increment * increment);

java/libraries/video/examples/Capture/FrameDifferencing/FrameDifferencing.pde

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ Capture video;
1414

1515
void setup() {
1616
size(640, 480, P2D);
17-
// Uses the default video input, see the reference if this causes an error
17+
18+
// This the default video input, see the GettingStartedCapture
19+
// example if it creates an error
1820
video = new Capture(this, width, height);
19-
video.start();
21+
22+
// Start capturing the images from the camera
23+
video.start();
24+
2025
numPixels = video.width * video.height;
2126
// Create an array to store the previously captured frame
2227
previousFrame = new int[numPixels];

java/libraries/video/examples/Capture/Framingham/Framingham.pde

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ int[] scoot;
2020
void setup() {
2121
size(640, 480, P2D);
2222

23-
// Uses the default video input, see the reference if this causes an error
23+
// This the default video input, see the GettingStartedCapture
24+
// example if it creates an error
2425
video = new Capture(this, 160, 120);
25-
video.start();
26-
// Also try with other video sizes
26+
27+
// Start capturing the images from the camera
28+
video.start();
2729

2830
column = 0;
2931
columnCount = width / video.width;

java/libraries/video/examples/Capture/GettingStartedCapture/GettingStartedCapture.pde

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* Getting Started with Capture.
33
*
44
* Reading and displaying an image from an attached Capture device.
5-
*/
6-
5+
*/
6+
77
import processing.video.*;
88

99
Capture cam;
@@ -12,29 +12,36 @@ void setup() {
1212
size(640, 480, P2D);
1313

1414
String[] cameras = Capture.list();
15-
15+
1616
if (cameras.length == 0) {
1717
println("There are no cameras available for capture.");
1818
exit();
19-
} else {
19+
}
20+
else {
2021
println("Available cameras:");
2122
for (int i = 0; i < cameras.length; i++) {
2223
println(cameras[i]);
2324
}
24-
25+
2526
// The camera can be initialized directly using an element
2627
// from the array returned by list():
2728
cam = new Capture(this, cameras[0]);
28-
cam.start();
29-
}
29+
// Or, the settings can be defined based on the text in the list
30+
//cam = new Capture(this, 640, 480, "Built-in iSight", 30);
31+
32+
// Start capturing the images from the camera
33+
cam.start();
34+
}
3035
}
3136

3237
void draw() {
3338
if (cam.available() == true) {
3439
cam.read();
3540
}
3641
image(cam, 0, 0);
37-
// The following does the same, and is faster when just drawing the image
38-
// without any additional resizing, transformations, or tint.
42+
// The following does the same as the above image() line, but
43+
// is faster when just drawing the image without any additional
44+
// resizing, transformations, or tint.
3945
//set(0, 0, cam);
40-
}
46+
}
47+

java/libraries/video/examples/Capture/HsvSpace/HsvSpace.pde

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,13 @@ boolean blobby = false;
3737
void setup() {
3838
size(640, 480, P3D);
3939

40+
// This the default video input, see the GettingStartedCapture
41+
// example if it creates an error
4042
video = new Capture(this, 160, 120);
41-
video.start();
43+
44+
// Start capturing the images from the camera
45+
video.start();
46+
4247
count = video.width * video.height;
4348

4449
sphereDetail(60);
@@ -63,8 +68,10 @@ void setup() {
6368
void draw() {
6469
background(0);
6570

66-
if (!blobby) lights();
67-
71+
if (!blobby) {
72+
lights();
73+
}
74+
6875
pushMatrix();
6976
translate(width/2, height/2);
7077
scale(min(width, height) / 10.0);

java/libraries/video/examples/Capture/LivePocky/LivePocky.pde

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ int buffer[];
1818
void setup() {
1919
size(600, 400, P2D);
2020

21-
// Uses the default video input, see the reference if this causes an error
21+
// This the default video input, see the GettingStartedCapture
22+
// example if it creates an error
2223
video = new Capture(this, 320, 240);
23-
video.start();
24+
25+
// Start capturing the images from the camera
26+
video.start();
2427

2528
maxRows = height * 2;
2629
buffer = new int[width * maxRows];

0 commit comments

Comments
 (0)