Modules
Face-detection
Face Detection
Description
Do face detection using openCV library.
Dependancies
This uobject requires openCV computer vision library.
Use in urbiscript
var face = new FaceDetection("camera.val", "path_to_some_opencv_detector.xml")
face.number; // number of visible faces
face.visible; // if someone is visible
face.area;
face.x; // position in x of the face center
face.y; // position in y of the face center
face.ray;
Example of use
- With Aldebaran NAO:
Makes the NAO follow some pink/orange object with the head:
Launch the FaceDetection UObject remotely on the NAO:
urbi-launch -r colormap.so -- -H <ip_of_nao> -p 54000
or install it on the NAO and do from urbi
loadLibrary("colormap.so")
Then connect with netcat or any telnet-like tool to the NAO and type:
var detector = "/usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml";
var Global.face = FaceDetection.new ("camera.val", detector);
var Global.speed = 0.2;
t:whenever (face.visible)
{
// Move the head toward the face
headYaw.val = headYaw.val + speed * camera.xfov * face.x &
headPitch.val = headPitch.val - speed * camera.yfov * face.y
},
// Activate head motors and camera.
camera.load = headPitch.load = headYaw.load = 1;
// Decrease camera refresh rate
camera.rate = 1;
// Activate the tracking
// There are two mode for this uobject: auto update at camera rate, do:
face.load = 1;
// Or do yourself the update, in this case do:
// face.load = 0
// u: every (1s) face.setImage (camera.val),
Replace "/usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml" by the path to this openCV detector on your computer.
- Downloads face-detection-opencv.tgz