We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Camera_as_sensor (Read 1178 times)
Camera_as_sensor
May 11th, 2008, 1:20pm
 
Hi, everyone.

I am working on a project which i want to use camera as sensor. When someone comes closer to the camera the real time video will become noisier.

Is this possible with processing?

Any advices will be very useful.

Thamks!
Re: Camera_as_sensor
Reply #1 - May 12th, 2008, 3:52am
 
If you can control the conditions of filming then it should be pretty easy. Like say the camera points at a black background. Run through the pixels of the camera input every few frames and keep a running tally. Less black = more noise.

Failing that you could try to use a blob or face tracking library to find the person and check how big they are from the previous to the current frame. Then use that information for the noise scale.

MattD
Re: Camera_as_sensor
Reply #2 - May 12th, 2008, 3:36pm
 
Is using the camera to judge the distance integral to the piece?

I think I'd use arduino board with a sonar ping sensor to judge the distance.
Re: Camera_as_sensor
Reply #3 - May 12th, 2008, 4:42pm
 
First of all thanks for the replies!

Yes i try to judge the distance between the camera and a person who come in the room if that you mean.

At first i make the noise.it works with Jmyron.This is the code.Where i have -- is the place where noise works.
Do you think i can continue working with Jmyron to judge the distance with globs or something else...or use face detect library or blob detection.Actually i don't have much time to finish it and a good advice will help me a lot! Can you give me more columns of using arduino lwhi???

import JMyron.*;

JMyron m;//a camera object
int max_index;
int index;
float randomness = 0;

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.findGlobs(0);//disable the intelligence to speed up frame rate
 println("Myron " + m.version());
-- max_index = width*height - 1;
}

void draw(){
 m.update();//update the camera view
 int[] img = m.image(); //get the normal image of the camera
--- randomness = randomness + 0.1;
--- if (randomness > 100) { randomness = 0; };
// -- randomness = randomness % 100;
 --loadPixels();
 --for(int i=0;i<width*height;i++){ //loop through all the pixels
 --  index = i + floor(random(0, randomness));
 --  index = min(index, max_index);
 --  pixels[index] = 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();
}
Re: Camera_as_sensor
Reply #4 - May 14th, 2008, 11:51am
 
I am having the following code but it doesn't work and i don't
understand why.. i want to judge the floor area of the rect
to be the value of the noise.Can someone help me?




import JMyron.*;

JMyron m;//a camera object
 int max_index;
int index;
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,255,255,200);//R, G, B, and range of similarity
 m.minDensity(500);
  max_index = width*height - 1; //minimum pixels in the glob required to result in a box
 println("Myron " + m.version());
 noFill();
}

void draw(){
 m.update();//update the camera view
int[] img = m.image();
 int[][] b = m.globBoxes();//get the center points
loadPixels();
 //draw the boxes
 stroke(255,255,0);
 for(int i=0;i<b.length;i++){
 rect( b[i][0] , b[i][1] , b[i][2] , b[i][3] );
    for(int j=0;j<width*height;j++){
     index = j + abs((((b[i][2] - b[i][0])*(b[i][3]-b[i][1])-800))/8);
     index = min(index, max_index);
   pixels[index] = img[j];
   println((b[i][2] - b[i][0])*(b[i][3]-b[i][1]));
     }
 }
//updatePixels();
}

Re: Camera_as_sensor
Reply #5 - Aug 7th, 2008, 8:15pm
 
I have the impression that you might have slightly misunderstood lwhi's comment above.

You want to measure the distance from your camera to a person entering the space and getting closer, right? Indeed, you *could* manage to do this by means of computer vision. Though I wouldn't want to: not a very robust solution (too dependent on your environment), much too much development time and processing power wasted for a task that can be simpler solved otherwise. In short: too much toil and trouble, don't waste your time with this.

I would recommend, as well, to rather not use the camera but a simple distance sensor like e. g. the Sharp GP2… series. (BTW, this is basically this is the same type of sensing used by cameras for autofocus.) You may quite easily connect such a sensor to your computer using a microcontroller board like Arduino and read its output from Processing via the serial library.
Page Index Toggle Pages: 1