Simple Head Tracking with OpenCV

I’m currently working a bit on Animabot’s software (Raspberry Pi side). I developed a small application for the Head Tracking which will be used on the robot. The application is developed in Python and using TkInter for the GUI. The software is using the standard Face Detection from OpenCV.

The program checks for face to detect, then provide the Head center position regarding the center of the video. It also sends the position trough UART is order to link the Pi to another board if needed (in my case, to the STM32F4). Or through socket if you want to use the info internally in the Pi. The output coordinates are filtered to have a more accurate position and avoid too much jitter.


This is a companion discussion topic for the original entry at https://community.robotshop.com/tutorials/show/simple-head-tracking-with-opencv

Nice work!
I also have plans to do something similar: I want a humanoid robot head to copy the facial expressions of a human performing on video.
OpenCV’s haarcascade is nice to have, but it’s sooo 2000’s tech :slight_smile: I’m planning to use Dlib’s face landmark detector for that:
http://blog.dlib.net/2014/08/real-time-face-pose-estimation.html
Dlib also have a ton of other algorithms, it has a general object tracker, so you don’t have to detect the face every frame, just detect it every 1-2s then track it with the tracker, then you can apply the face landmark detection.

Thanks !
Well I don’t know if OpenCV’s haarcascade is sooo 2000’s tech but it does the job :wink: But Dlib doesn’t look bad, I will definitely look into it.
I start to have good knowledge with OpenCV and I can know do some very nice stuff (face recognition, object tracking, pedestrian tracking, etc…) and I know it can be used within ROS (which I plan to use afterwards) maybe Dlib as well, I haven’t look yet… but thanks for the tip :wink: