Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
varvaras
varvaras's Profile
1
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
OpenCV Face Recognition How To Question: only print/speak twitter update while face is detected
[0 Replies]
15-Jun-2011 09:18 AM
Forum:
Contributed Library Questions
hi, for an art project I'm writing a Processing sketch with OpenCV
library (Face Detection) and twitter streaming library.
I want it so that
only
if a face is currently detected the stream starts/continues.
so something like:
if (face detected == true) {
-- do something (println/speak "twitter update")
} else {
println ("please hold your face in front of the camera for the stream to continue")
}
Does anyone have any suggestions??
here's a sample from the sketch:
void draw() {
background(0);
// grab a new frame
// and convert to gray
opencv.read();
opencv.convert( GRAY );
// proceed detection
Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 );
// display the image
image( opencv.image(), 0, 0 );
// draw face area(s)
noFill();
stroke(255,0,0);
for( int i=0; i<faces.length; i++ ) {
image( a, faces[i].x, faces[i].y, faces[i].width, faces[i].height );
//image( b, faces[i].x, faces[i].y, faces[i].width, faces[i].height );
}
}
// called by twitter stream whenever a new tweet comes in
void tweet(Status tweet) {
// if (face detection==true) {
println(tweets + " - You've got a new message: " + tweet.text());
tweetText = tweet.text();
tts.speak(tweetText);
tweets += 1;
// } else println "keep your face in front of the camera to receive new messages!"
}
UPDATE: THIS SEEMS TO WORK:
void draw() {
background(0);
// grab a new frame
// and convert to gray
opencv.read();
opencv.convert( GRAY );
// proceed detection
Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 );
// display the image
image( opencv.image(), 0, 0 );
// draw face area(s)
noFill();
stroke(255,0,0);
for( int i=0; i<faces.length; i++ ) {
Rectangle(faces[i].x, faces[i].y, faces[i].width, faces[i].height );
//image( b, faces[i].x, faces[i].y, faces[i].width, faces[i].height );
detect = true;
}
for( int i=0; i==faces.length; i++ ) {
detect=false;
}
}
// called by twitter stream whenever a new tweet comes in
void tweet(Status tweet) {
// if (face detection==true) {
if(detect==true){
println(tweets + " - You've got a new message: " + tweet.text());
tweetText = tweet.text();
tts.speak(tweetText);
// } else println "keep your face in front of the camera to receive new messages!"
} else {
println("keep your face in front of the camera");
}
tweets += 1;
}
«Prev
Next »
Moderate user : varvaras
Forum