top of page


We are going to see how to built a camera that can detect and track faces .



A webcam capture and feeds images to a program running on a computer .
The program process the images to detect faces .
If no face is detected in the image the camera will start randomly roaming until it finds a face to track .

If a face is detected the camera will try to move to get the detected face in the centre of image .

The camera movement is handled by 2 servos controlled by an arduino Uno communicating with the face tracking program using serial communication through USB .


The 3 LED's on the case let us know the state of the tracking :

 - Red : no face detected .

 - Yellow : face detected but not in the center of the image .

 - Green :face detected and in the center of the image .


*** disclaimer : some of the links below are affiliate links, this means I get a small commission when you purchase using them ( at no extra cost to you ) . If you like this website please consider using them but you don't have to ! ***


 - Arduino Uno R3

 - 2 x MG-90S servos (You can also use SG-90 servos)

 - Webcam

 - Power supply ( needs to deliver over 7 volts and 2 amps )

 - 5V voltage regulator

 - 2.1x5.5mm jack plug

 - male pin header

 - heatshrink tubing

 - M2x10mm self tapping screw

 - rubber band ( you can also use zip ties )

 - paperclip

 - wires

 - 3 x LED ( optional )

 - 3 x 220 ohm resistor ( optional )



 - screwdriver
 - something to check dimensions, a ruler or a caliper
 - wire stripper
 - pliers
 - soldering iron
 - multi-meter .


*** If you do not have access to a 3D printer check the



Here are the 8 parts you will need to print :

 - Camera holder arm

 - Upper bracket

 - Lower bracket

 - LED lock

 - Short axle end

 - Long axle end

 - Stand

 - Case











1 . Fit the upper bracket to the camera holder arm using the short axle end (on the side of the camera holder arm with the groove ) .

2 . Screw the long axle end to the upper bracket .
Make sure the parts move freely but without excessive play .

3 . If your webcam has a stand, remove it .

4 . Use a few rubber bands to hold the webcam on its arm .

5 . Screw the pan servo onto the upper bracket . Hold the servo and webcam cables between the servo and the upper bracket .

6 . Screw the tilt servo onto the upper bracket .

7 . Fit the lower bracket and screw both servos on it .

8 . Screw the stand on the case .

9 . Screw the pan servo horn on the stand and trim any excess length .

10 . Unfold the paper clip to get a straight rod . Then create a couple of 90 degrees bends 30 mm apart .

11 . Fit one end of the rod in the pinhole on the side of the camera holder arm .

Then slide the tilt servo horn on the other end .

We will need to set up the servos before bolting the horn onto the servo .

12 . Mark the tilt servo wire . It will help to identify each servo once everything is assembled .

13 . Pass the servo wires through the hole at the top of the case .

14 . You can then temporary mount the camera assembly to the case .

It will have to come off after setting up the servos .

The assembly is pretty much done !!! We just have to take care of the wiring before being able to bolt the servo horns in their final position .


Once everything is done you should end up with something like this .

wiring photo assembly here

software (and servos setup) .

We will now see how to use the software and setup the servos .

The software comes in 2 version :

 - An executable that you just have to download and run (this is great if you can't code .  unfortunately this only works on windows) .

 - And a repository including all the python, UI and haar cascade file required to run the program . Feel free to improve and build upon the existing code !

1 . The software comes with an arduino sketch named "Camera_tracking.ino" .

Upload it to the arduino .

Then unplug the arduino from the computer .

2 . Temporary plug the servos to the arduino then plug the power supply to the jack .

The sketch we just uploaded includes a starting routine that involve the position of both servo to be set at 90 degrees . 

3 . Carefully unscrew the pan servo horn without changing the servo position and remount the camera facing forward . 

4 . Fit the tilt servo horn to get the camera to point straight forward .

5 . Fit the jack and voltage regulator to the case . 

6 . Fit the LED's to the case using the LED lock part . 

6 . Seal everything by screwing the arduino to the case .

7 . Plug the power supply to your arduino, plug the arduino to you computer and don't forget to also plug the USB webcam .
Then start the face tracking software  .

8 . You might get a warning message since I am not a certified Microsoft developer . You can ignore it or if you don't trust me use the python file and check the code for yourself . I won't blame you for Being too careful !!!

bottom of page