Droobie
YaBB Newbies
Offline
Posts: 2
How can i draw with color detection?
Mar 29th , 2007, 9:32am
Heey guys, i try to make a draw program with a webcam. I want that people are standing for the webcam and that they can draw with a colored point (for example a laser pointer). I got a code with color detection, and i got a code to draw lines on the screen, but now i have to combine it. The problem is, how to do that... i have really no idea, because i'am new with this program and i'am trying to learn te basics. if you guys can help me many thnx grTz Droobie ---- code for color detection ---- import JMyron.*; JMyron m;//a camera object void setup(){ size(320,240); m = new JMyron();//make a new instance of the object m.start(width,height);//start a capture at 320x240 m.trackColor(255,0,0,200);//R, G, B, and range of similarity m.minDensity(100); //minimum pixels in the glob required to result in a box println("Myron " + m.version()); noFill(); } void draw(){ m.update();//update the camera view drawCamera();//draw the camera to the screen int[][] b = m.globBoxes();//get the center points //draw the boxes stroke(255,255,255); for(int i=0;i<b.length;i++){ //line(mouseX, mouseY, pmouseX, pmouseY); rect( b[i][0] , b[i][1] , b[i][2] , b[i][3] ); } } void drawCamera(){ int[] img = m.image(); //get the normal image of the camera loadPixels(); for(int i=0;i<width*height;i++){ //loop through all the pixels pixels[i] = img[i]; //draw each pixel to the screen } updatePixels(); } void mousePressed(){ // m.settings();//click the window to get the settings } public void stop(){ m.stop();//stop the object super.stop(); } --- end code for color detection --- --- code to draw on a grid --- void setup() { size(200, 200); background(000); } void draw() { stroke(255); if(mousePressed) { line(mouseX, mouseY, pmouseX, pmouseY); } } --- end code to draw on a grid