From 26e6038f61ae10ec69afeea2d0fa5509dcf000ec Mon Sep 17 00:00:00 2001 From: codeanticode Date: Wed, 15 Aug 2012 22:18:15 +0000 Subject: [PATCH] Updated capture examples --- .../GettingStartedCapture.pde | 19 +++++-------------- .../examples/Capture/LivePocky/LivePocky.pde | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/java/libraries/video/examples/Capture/GettingStartedCapture/GettingStartedCapture.pde b/java/libraries/video/examples/Capture/GettingStartedCapture/GettingStartedCapture.pde index 28ec1600f..9d5c2a1c8 100644 --- a/java/libraries/video/examples/Capture/GettingStartedCapture/GettingStartedCapture.pde +++ b/java/libraries/video/examples/Capture/GettingStartedCapture/GettingStartedCapture.pde @@ -22,19 +22,10 @@ void setup() { println(cameras[i]); } - cam = new Capture(this, 320, 240, cameras[0]); - cam.start(); - - // You can get the list of resolutions (width x height x fps) - // supported capture device by calling the resolutions() - // method. It must be called after creating the capture - // object. - Resolution[] res = cam.resolutions(); - println("Supported resolutions:"); - for (int i = 0; i < res.length; i++) { - println(res[i].width + "x" + res[i].height + ", " + - res[i].fps + " fps (" + res[i].fpsString +")"); - } + // The camera can be initialized directly using an element + // from the array returned by list(): + cam = new Capture(this, cameras[0]); + cam.start(); } } @@ -46,4 +37,4 @@ void draw() { // The following does the same, and 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/LivePocky/LivePocky.pde b/java/libraries/video/examples/Capture/LivePocky/LivePocky.pde index 3dbe46c24..3eee7735d 100644 --- a/java/libraries/video/examples/Capture/LivePocky/LivePocky.pde +++ b/java/libraries/video/examples/Capture/LivePocky/LivePocky.pde @@ -19,7 +19,7 @@ void setup() { size(600, 400, P2D); // Uses the default video input, see the reference if this causes an error - video = new Capture(this, 160, 120); + video = new Capture(this, 320, 240); video.start(); maxRows = height * 2; @@ -34,6 +34,14 @@ void setup() { void draw() { + video.loadPixels(); + arraycopy(video.pixels, 0, buffer, writeRow * width, width); + writeRow++; + if (writeRow == maxRows) { + writeRow = 0; + } + topRow++; + for (int y = 0; y < height; y++) { int row = (topRow + y) % maxRows; arraycopy(buffer, row * width, g.pixels, y*width, width); @@ -44,11 +52,4 @@ void draw() { void captureEvent(Capture c) { c.read(); - c.loadPixels(); - arraycopy(c.pixels, 0, buffer, writeRow * width, width); - writeRow++; - if (writeRow == maxRows) { - writeRow = 0; - } - topRow++; -} +} \ No newline at end of file