BigBLilD
YaBB Newbies
Offline
Posts: 1
Really need help Tracing with JMyron
Dec 3rd , 2008, 11:22pm
We are new to Processing and are currently writing a code which tracks and traces the color RED using a Webcam. We have figured out how to track the color using a filled circle, however, we would also like to draw the movement of the circle across the screen and use a time delayed fading effect (i.e. like a digital pen). Below is the code we have so far. If someone would kindly help us figure out the necessary command for tracing and delayed fading of the red circle, it would be very greatly appreciated. Thanks! Bd import JMyron.*; JMyron theMov; int[][] globArray; int tolerance =10; int tailFactor=20; void setup() { size(640, 480); theMov = new JMyron(); theMov.start(width, height); theMov.findGlobs(1); theMov.minDensity(255); theMov.trackColor(255, 0, 0, 200); stroke(200,0,0); // white outline } void draw() { theMov.update(); int[] currFrame = theMov.image(); // draw each pixel to the screen loadPixels(); for (int i = 0; i < width*height; i++) { pixels[i] = currFrame[i]; } updatePixels(); // draw the glob contours globArray = theMov.globBoxes(); for (int i=0; i < globArray.length; i++){ int[] boxArray = globArray[i]; // set the fill colour to the average of all colours in the bounding box int currColor = theMov.average( boxArray[0], boxArray[1], boxArray[0] + boxArray[2], boxArray[1] + boxArray[3]); fill(200,0,0); ellipseMode(CORNER);// The specified x and y is the upper left corner ellipse(boxArray[0], boxArray[1], boxArray[2], boxArray[3]); } } public void stop() { theMov.stop(); super.stop(); }