Hello, for my study project I want to integrate face detection to use it in a if-statement to output a signal with arduino.
So what I want to accomplish:
If Processing/OpenCV detects a face, it writes the number of faces to my arduino. And in arduino I want a simple statement that it only digitalWrites to a pin when the number of faces is 1 and above. The problem is, that at the moment, the led turns on when it detects my face. After covering the camera it turns off, and after removing my finger and let it recognize my face, it turns back on. But then it stays on, i can't seem to turn it off as it should.
EDIT: It seems that the led turns off at a random time, so sometimes it is very fast (even faster then waiting for 1000 ms) and sometimes it takes really long (about 10 sec). It even seems that, how longer it detects my face, how longer the led stays on. So if I let it detect my face for a short time, the led will go turn off faster.
Hopefully I am not too vague and that my english is good enough to understand.
The code in Processing
import hypermedia.video.*;
import java.awt.Rectangle;
import processing.serial.*;
OpenCV opencv;
Serial port;
// contrast/brightness values
int contrast_value = 0;
int brightness_value = 0;
void setup() {
size( 640, 480 );
opencv = new OpenCV( this );
opencv.capture( width, height ); // open video stream
opencv.cascade( "C:\\OpenCV\\data\\haarcascades\\haarcascade_frontalface_alt.xml" ); // load detection description, here-> front face detection : "haarcascade_frontalface_alt.xml"
println(Serial.list());
port = new Serial(this, Serial.list()[0],9600);
// print usage
println( "Drag mouse on X-axis inside this sketch window to change contrast" );
println( "Drag mouse on Y-axis inside this sketch window to change brightness" );