diff --git a/java/keywords.txt b/java/keywords.txt index 7710ab920..4cf38720c 100644 --- a/java/keywords.txt +++ b/java/keywords.txt @@ -526,7 +526,7 @@ parseXML FUNCTION1 parseXML_ perspective FUNCTION1 perspective_ PFont KEYWORD5 PFont list FUNCTION1 PFont_list_ -PGraphics FUNCTION1 PGraphics_ +PGraphics KEYWORD5 PGraphics beginDraw FUNCTION2 PGraphics_beginDraw_ endDraw FUNCTION2 PGraphics_endDraw_ PI LITERAL2 PI diff --git a/java/libraries/video/examples/Capture/AsciiVideo/AsciiVideo.pde b/java/libraries/video/examples/Capture/AsciiVideo/AsciiVideo.pde index b332e59e3..01188fa0b 100644 --- a/java/libraries/video/examples/Capture/AsciiVideo/AsciiVideo.pde +++ b/java/libraries/video/examples/Capture/AsciiVideo/AsciiVideo.pde @@ -29,11 +29,15 @@ float fontSize = 1.5; void setup() { size(640, 480, P2D); - // Uses the default video input, see the reference if this causes an error + // This the default video input, see the GettingStartedCapture + // example if it creates an error video = new Capture(this, 160, 120); + + // Start capturing the images from the camera video.start(); + int count = video.width * video.height; - println(count); + //println(count); font = loadFont("UniversLTStd-Light-48.vlw"); diff --git a/java/libraries/video/examples/Capture/BackgroundSubtraction/BackgroundSubtraction.pde b/java/libraries/video/examples/Capture/BackgroundSubtraction/BackgroundSubtraction.pde index 859a6af63..dfcedd525 100644 --- a/java/libraries/video/examples/Capture/BackgroundSubtraction/BackgroundSubtraction.pde +++ b/java/libraries/video/examples/Capture/BackgroundSubtraction/BackgroundSubtraction.pde @@ -15,9 +15,15 @@ Capture video; void setup() { size(640, 480, P2D); - // Uses the default video input, see the reference if this causes an error + + // This the default video input, see the GettingStartedCapture + // example if it creates an error + video = new Capture(this, 160, 120); video = new Capture(this, width, height); + + // Start capturing the images from the camera video.start(); + numPixels = video.width * video.height; // Create array to store the background image backgroundPixels = new int[numPixels]; @@ -36,11 +42,11 @@ void draw() { // of the background in that spot color currColor = video.pixels[i]; color bkgdColor = backgroundPixels[i]; - // Extract the red, green, and blue components of the current pixel�s color + // Extract the red, green, and blue components of the current pixel's color int currR = (currColor >> 16) & 0xFF; int currG = (currColor >> 8) & 0xFF; int currB = currColor & 0xFF; - // Extract the red, green, and blue components of the background pixel�s color + // Extract the red, green, and blue components of the background pixel's color int bkgdR = (bkgdColor >> 16) & 0xFF; int bkgdG = (bkgdColor >> 8) & 0xFF; int bkgdB = bkgdColor & 0xFF; @@ -61,7 +67,7 @@ void draw() { } // When a key is pressed, capture the background image into the backgroundPixels -// buffer, by copying each of the current frame�s pixels into it. +// buffer, by copying each of the current frame's pixels into it. void keyPressed() { video.loadPixels(); arraycopy(video.pixels, backgroundPixels); diff --git a/java/libraries/video/examples/Capture/BrightnessThresholding/BrightnessThresholding.pde b/java/libraries/video/examples/Capture/BrightnessThresholding/BrightnessThresholding.pde index 0de1b4f98..f2ee1a0bc 100644 --- a/java/libraries/video/examples/Capture/BrightnessThresholding/BrightnessThresholding.pde +++ b/java/libraries/video/examples/Capture/BrightnessThresholding/BrightnessThresholding.pde @@ -17,9 +17,14 @@ Capture video; void setup() { size(640, 480, P2D); // Change size to 320 x 240 if too slow at 640 x 480 strokeWeight(5); - // Uses the default video input, see the reference if this causes an error + + // This the default video input, see the GettingStartedCapture + // example if it creates an error video = new Capture(this, width, height); - video.start(); + + // Start capturing the images from the camera + video.start(); + numPixels = video.width * video.height; noCursor(); smooth(); diff --git a/java/libraries/video/examples/Capture/ColorSorting/ColorSorting.pde b/java/libraries/video/examples/Capture/ColorSorting/ColorSorting.pde index f84e63571..34be988ba 100644 --- a/java/libraries/video/examples/Capture/ColorSorting/ColorSorting.pde +++ b/java/libraries/video/examples/Capture/ColorSorting/ColorSorting.pde @@ -19,13 +19,14 @@ int[] bright; // How many pixels to skip in either direction int increment = 5; - void setup() { size(800, 600, P2D); - - noCursor(); - // Uses the default video input, see the reference if this causes an error + + // This the default video input, see the GettingStartedCapture + // example if it creates an error video = new Capture(this, 160, 120); + + // Start capturing the images from the camera video.start(); int count = (video.width * video.height) / (increment * increment); diff --git a/java/libraries/video/examples/Capture/FrameDifferencing/FrameDifferencing.pde b/java/libraries/video/examples/Capture/FrameDifferencing/FrameDifferencing.pde index e85dc4a9b..0350ab080 100644 --- a/java/libraries/video/examples/Capture/FrameDifferencing/FrameDifferencing.pde +++ b/java/libraries/video/examples/Capture/FrameDifferencing/FrameDifferencing.pde @@ -14,9 +14,14 @@ Capture video; void setup() { size(640, 480, P2D); - // Uses the default video input, see the reference if this causes an error + + // This the default video input, see the GettingStartedCapture + // example if it creates an error video = new Capture(this, width, height); - video.start(); + + // Start capturing the images from the camera + video.start(); + numPixels = video.width * video.height; // Create an array to store the previously captured frame previousFrame = new int[numPixels]; diff --git a/java/libraries/video/examples/Capture/Framingham/Framingham.pde b/java/libraries/video/examples/Capture/Framingham/Framingham.pde index a53b94321..8fcb8b1e8 100644 --- a/java/libraries/video/examples/Capture/Framingham/Framingham.pde +++ b/java/libraries/video/examples/Capture/Framingham/Framingham.pde @@ -20,10 +20,12 @@ int[] scoot; void setup() { size(640, 480, P2D); - // Uses the default video input, see the reference if this causes an error + // This the default video input, see the GettingStartedCapture + // example if it creates an error video = new Capture(this, 160, 120); - video.start(); - // Also try with other video sizes + + // Start capturing the images from the camera + video.start(); column = 0; columnCount = width / video.width; diff --git a/java/libraries/video/examples/Capture/GettingStartedCapture/GettingStartedCapture.pde b/java/libraries/video/examples/Capture/GettingStartedCapture/GettingStartedCapture.pde index 9d5c2a1c8..22012c7b4 100644 --- a/java/libraries/video/examples/Capture/GettingStartedCapture/GettingStartedCapture.pde +++ b/java/libraries/video/examples/Capture/GettingStartedCapture/GettingStartedCapture.pde @@ -2,8 +2,8 @@ * Getting Started with Capture. * * Reading and displaying an image from an attached Capture device. - */ - + */ + import processing.video.*; Capture cam; @@ -12,21 +12,26 @@ void setup() { size(640, 480, P2D); String[] cameras = Capture.list(); - + if (cameras.length == 0) { println("There are no cameras available for capture."); exit(); - } else { + } + else { println("Available cameras:"); for (int i = 0; i < cameras.length; i++) { println(cameras[i]); } - + // The camera can be initialized directly using an element // from the array returned by list(): cam = new Capture(this, cameras[0]); - cam.start(); - } + // Or, the settings can be defined based on the text in the list + //cam = new Capture(this, 640, 480, "Built-in iSight", 30); + + // Start capturing the images from the camera + cam.start(); + } } void draw() { @@ -34,7 +39,9 @@ void draw() { cam.read(); } image(cam, 0, 0); - // The following does the same, and is faster when just drawing the image - // without any additional resizing, transformations, or tint. + // The following does the same as the above image() line, but + // is faster when just drawing the image without any additional + // resizing, transformations, or tint. //set(0, 0, cam); -} \ No newline at end of file +} + diff --git a/java/libraries/video/examples/Capture/HsvSpace/HsvSpace.pde b/java/libraries/video/examples/Capture/HsvSpace/HsvSpace.pde index 9faf65dcd..9f72fe96f 100644 --- a/java/libraries/video/examples/Capture/HsvSpace/HsvSpace.pde +++ b/java/libraries/video/examples/Capture/HsvSpace/HsvSpace.pde @@ -37,8 +37,13 @@ boolean blobby = false; void setup() { size(640, 480, P3D); + // This the default video input, see the GettingStartedCapture + // example if it creates an error video = new Capture(this, 160, 120); - video.start(); + + // Start capturing the images from the camera + video.start(); + count = video.width * video.height; sphereDetail(60); @@ -63,8 +68,10 @@ void setup() { void draw() { background(0); - if (!blobby) lights(); - + if (!blobby) { + lights(); + } + pushMatrix(); translate(width/2, height/2); scale(min(width, height) / 10.0); diff --git a/java/libraries/video/examples/Capture/LivePocky/LivePocky.pde b/java/libraries/video/examples/Capture/LivePocky/LivePocky.pde index 1e6395419..3425caad8 100644 --- a/java/libraries/video/examples/Capture/LivePocky/LivePocky.pde +++ b/java/libraries/video/examples/Capture/LivePocky/LivePocky.pde @@ -18,9 +18,12 @@ int buffer[]; void setup() { size(600, 400, P2D); - // Uses the default video input, see the reference if this causes an error + // This the default video input, see the GettingStartedCapture + // example if it creates an error video = new Capture(this, 320, 240); - video.start(); + + // Start capturing the images from the camera + video.start(); maxRows = height * 2; buffer = new int[width * maxRows]; diff --git a/java/libraries/video/examples/Capture/Mirror/Mirror.pde b/java/libraries/video/examples/Capture/Mirror/Mirror.pde index 5ef7520a2..abd69f7f9 100644 --- a/java/libraries/video/examples/Capture/Mirror/Mirror.pde +++ b/java/libraries/video/examples/Capture/Mirror/Mirror.pde @@ -23,9 +23,12 @@ void setup() { rows = height / cellSize; colorMode(RGB, 255, 255, 255, 100); - // Uses the default video input, see the reference if this causes an error + // This the default video input, see the GettingStartedCapture + // example if it creates an error video = new Capture(this, width, height); - video.start(); + + // Start capturing the images from the camera + video.start(); background(0); } @@ -35,9 +38,6 @@ void draw() { if (video.available()) { video.read(); video.loadPixels(); - - // Not bothering to clear background - // background(0); // Begin loop for columns for (int i = 0; i < cols; i++) { diff --git a/java/libraries/video/examples/Capture/Mirror2/Mirror2.pde b/java/libraries/video/examples/Capture/Mirror2/Mirror2.pde index 4c565fa2b..da415c8c1 100644 --- a/java/libraries/video/examples/Capture/Mirror2/Mirror2.pde +++ b/java/libraries/video/examples/Capture/Mirror2/Mirror2.pde @@ -23,9 +23,12 @@ void setup() { colorMode(RGB, 255, 255, 255, 100); rectMode(CENTER); - // Uses the default video input, see the reference if this causes an error + // This the default video input, see the GettingStartedCapture + // example if it creates an error video = new Capture(this, width, height); - video.start(); + + // Start capturing the images from the camera + video.start(); background(0); } diff --git a/java/libraries/video/examples/Capture/RadialPocky/RadialPocky.pde b/java/libraries/video/examples/Capture/RadialPocky/RadialPocky.pde index a4e640204..df41a9065 100644 --- a/java/libraries/video/examples/Capture/RadialPocky/RadialPocky.pde +++ b/java/libraries/video/examples/Capture/RadialPocky/RadialPocky.pde @@ -21,9 +21,13 @@ void setup() { // size must be set to video.width*video.height*2 in both directions size(600, 600, P2D); - // Uses the default video input, see the reference if this causes an error + // This the default video input, see the GettingStartedCapture + // example if it creates an error video = new Capture(this, 160, 120); - video.start(); + + // Start capturing the images from the camera + video.start(); + videoCount = video.width * video.height; pixelCount = width*height; @@ -70,6 +74,8 @@ void draw() { updatePixels(); currentAngle++; - if (currentAngle == angleCount) currentAngle = 0; + if (currentAngle == angleCount) { + currentAngle = 0; + } } } diff --git a/java/libraries/video/examples/Capture/SlitScan/SlitScan.pde b/java/libraries/video/examples/Capture/SlitScan/SlitScan.pde index f33927317..c58189245 100644 --- a/java/libraries/video/examples/Capture/SlitScan/SlitScan.pde +++ b/java/libraries/video/examples/Capture/SlitScan/SlitScan.pde @@ -7,6 +7,8 @@ * consider using the image copy() function rather than the * direct pixel-accessing approach I have used here. */ + + import processing.video.*; Capture video; @@ -17,9 +19,12 @@ int drawPositionX; void setup() { size(600, 240, P2D); - // Uses the default video input, see the reference if this causes an error - video = new Capture(this, 320, 240); - video.start(); + // This the default video input, see the GettingStartedCapture + // example if it creates an error + video = new Capture(this,320, 240); + + // Start capturing the images from the camera + video.start(); videoSliceX = video.width / 2; drawPositionX = width - 1; diff --git a/java/libraries/video/examples/Capture/Spatiotemporal/Spatiotemporal.pde b/java/libraries/video/examples/Capture/Spatiotemporal/Spatiotemporal.pde index 0eb682bcd..24a1a83d4 100644 --- a/java/libraries/video/examples/Capture/Spatiotemporal/Spatiotemporal.pde +++ b/java/libraries/video/examples/Capture/Spatiotemporal/Spatiotemporal.pde @@ -24,8 +24,13 @@ int currentX = 0; void setup() { size(640, 480); - video = new Capture(this, width, height, 30); - video.start(); + + // This the default video input, see the GettingStartedCapture + // example if it creates an error + video = new Capture(this, width, height); + + // Start capturing the images from the camera + video.start(); } void captureEvent(Capture c) { diff --git a/java/libraries/video/examples/Capture/TimeDisplacement/TimeDisplacement.pde b/java/libraries/video/examples/Capture/TimeDisplacement/TimeDisplacement.pde index cf2847845..460f8adcf 100644 --- a/java/libraries/video/examples/Capture/TimeDisplacement/TimeDisplacement.pde +++ b/java/libraries/video/examples/Capture/TimeDisplacement/TimeDisplacement.pde @@ -16,42 +16,47 @@ ArrayList frames = new ArrayList(); void setup() { size(640, 480); - video = new Capture(this, width, height, 30); - video.start(); + + // This the default video input, see the GettingStartedCapture + // example if it creates an error + video = new Capture(this, width, height); + + // Start capturing the images from the camera + video.start(); } void captureEvent(Capture camera) { camera.read(); - //copy the current video frame into an image, so it can be stored in the buffer + // Copy the current video frame into an image, so it can be stored in the buffer PImage img = createImage(width, height, RGB); video.loadPixels(); arrayCopy(video.pixels, img.pixels); frames.add(img); - //once there are enough frames, remove the oldest one when adding a new one + // Once there are enough frames, remove the oldest one when adding a new one if (frames.size() > height/4) { frames.remove(0); } } void draw() { - //set the image counter to 0 + // Set the image counter to 0 int currentImage = 0; loadPixels(); - //begin a loop for displaying pixel rows of 4 pixels height + // Begin a loop for displaying pixel rows of 4 pixels height for (int y = 0; y < video.height; y+=4) { - //go through the frame buffer and pick an image, starting with the oldest one + // Go through the frame buffer and pick an image, starting with the oldest one if (currentImage < frames.size()) { PImage img = (PImage)frames.get(currentImage); if (img != null) { img.loadPixels(); - //put 4 rows of pixels on the screen + // Put 4 rows of pixels on the screen for (int x = 0; x < video.width; x++) { pixels[x + y * width] = img.pixels[x + y * video.width]; pixels[x + (y + 1) * width] = img.pixels[x + (y + 1) * video.width]; @@ -60,7 +65,7 @@ void draw() { } } - //increase the image counter + // Increase the image counter currentImage++; } else { @@ -70,7 +75,7 @@ void draw() { updatePixels(); - //for recording an image sequence + // For recording an image sequence //saveFrame("frame-####.jpg"); }