Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

webcam light-drawing

$
0
0

...basically I want to go on with a tutorial I found. My aim is to draw a continous curve by capturing light(brigthness) via the webcam. The problem I have at the moment is that the drawn ellipse is always refreshed, so I don't see a curve but just a circle... Thanks!

import processing.video.*; Capture cam; int x,y;

void setup (){ size (640,480); frameRate (30); background (0);

printArray (Capture.list()); //choose Webcam, change according the size! //cam = new Capture (this, 640,480, "Logitech QuickCam Express/Go",30); cam = new Capture (this, 640,480, "Integrated Camera",30); cam.start(); }

void draw (){

if (cam.available()){ cam.read(); cam.loadPixels(); float maxBri = 0.0; int theBrightPixel=0; for (int i=0; i<cam.pixels.length; i++){ if(brightness(cam.pixels[i]) > maxBri){ //find the brightest maxBri = brightness (cam.pixels[i]); theBrightPixel =i; //store id of brightest pixel } } x= theBrightPixel % cam.width; //find x with modolo y= theBrightPixel /cam.width; //find y with int, row

} image (cam,0,0); fill (255,0,0); ellipse (x,y,20,20); }


Viewing all articles
Browse latest Browse all 2896

Trending Articles