Face Tracking Turret

pan-tilt-mountFace tracking turret uses OpenCV framework for face recognition, the project is written in Python. The face center coordinate is sent via serial interface to Arduino. The coordinate is translated into horizontal and vertical angles that are used to position the servos on the pan/tilt mount.


Python code: https://github.com/lukagabric/TurretPython
Arduino code: https://github.com/lukagabric/TurretArduino


  • turret1
  • turret2
  • turret3


If you liked this blog post I’d appreciate if you followed me on Twitter

Related Post

Remember to share...Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInEmail this to someone

11 thoughts on “Face Tracking Turret

  1. Hi, it looks cool! Which servo did you use and how did you put it all together (mechanically) – can you provide some more images?

    Thank you for the post!

    1. Hi, I used two 9g SG90 Micro Servos and 9/12g pan/tilt micro servo mount. Look it up on ebay. I also uploaded a few images, hope that helps. Cheers!

      1. I looks like you have already done the job I have been trying to do. Would you be interested in assisting me in this project? Please email me and let me know ASAP. I really need the help and would be willing to pay for it.

  2. Hardware Wise, You can use the Servo City Kits.
    These are fast and simple to assemble. Scroll down on the page till you get to the smaller “Pan Tilt” sets. I am using the SPT – 200

    Interface wise, You need to wire the power to the servos and hook servo signals up to the Ardunio Controller. or get an adapter.

    This Sensor Shield just plugs into the Arduino board and allows direct servo plugin without the need of any external wiring. In other words, it eliminates the breadboard. I am using it now on an extremely similar project. Mine doesnt track faces, Just center of mass. I have this very same project except without the picture of the girl on the servo, I have a paintball gun instead that shoots unliked people and animals. lol, I can send a few pics of the smaller prototype I use for programming and development. Its using the SPT-200 Parts and you can see how the sheld is on it and how the servos connect. It really simplifies the connections. Electrically its exactly the same as how his is wired, just eliminates the breadboard.

    1. Linked the site I have been gathering information form for my project of similar origin. Electrical and other things are all on this site. You can pretty much build a fully working one of these robotic arms from this site. The only real difference between his project and ours, is the Software.
      Our Software is linked on Rudolph Labs website. It will target center of mass and has ballistics to calculate trajectory to shoot at a moving target and such. Its open source.
      We would be interested in getting the software for your project if you would like to open source it. It would be interesting to see if we can get our sentry guns to identify targets before engaging the targets using facial recognize technology.

  3. Awsome job,and thank you for shareing you code with everyone.
    Is there a link that you shows how to add OpenCV to the raspberry pi?
    Is the raspberry and Arduino communicating threw I2C?
    Thank you,

  4. Hello,

    He had a question .. I made the code for the web camera with pan tilt follow my face .. but have a problem when the program takes 2 or 3 minutes by detecting faces and sending the coordinates for serial to Arduino using python , open cv it stays frozen until leave the visual field of the webcam and this stops detecting , I ‘ve tried on two computers with windows and ubuntu, its power is high , so I do not think it hardware problem, I also lowered the resolution to:

    img = cv2.resize ( img , ( 0,0) , fx = 0.5 , f = 0.5)

    So I do not think it pc problem , I think it’s something Arduino , the buffer fills or something , I do not quite understand , I wonder if someone did the same to me, and I can solve .

    Posting the code if anyone can help me.

    Thank you very much !

  5. hey there guy im a former Basic C++ and have never used Python so im not sure what to do with this python side of the setup, is their a program i should download in order to run this control program ?

  6. Hello !

    Thank you for your code, you have made a nice job !
    But I have a little issue, when I use the camera of my laptop there is no issue, the servos track my head but when I use a webcam on the pan/tilt support the movements are too high (the servo turn too far and my head is not on the image).
    That’s why I am trying to change some figure but I don’t have really determine which figure is linked with the position of the servo. Can you help me ?

    A french student

    1. hello, when i try to do it, the pan tilt system don’t move correctly in the x,y point !! and my face isn’t in the center of the frame!!! i need help please…

Leave a Reply

Your email address will not be published. Required fields are marked *