0% found this document useful (0 votes)
122 views4 pages

Face Detection and Tracking With Arduino and OpenCV

This document describes a project using an Arduino, OpenCV, and a webcam to detect and track human faces. The system uses OpenCV and Python on a PC to detect faces in webcam video. When a face is detected, its position and size are sent over serial to an Arduino, which controls motors on a chassis to move the bot and keep the face centered in the webcam view. The hardware includes an Arduino, chassis, webcam, and motor driver. The algorithm detects faces using OpenCV and directs the bot's movement based on face position data.

Uploaded by

Sixsigma Tqm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
122 views4 pages

Face Detection and Tracking With Arduino and OpenCV

This document describes a project using an Arduino, OpenCV, and a webcam to detect and track human faces. The system uses OpenCV and Python on a PC to detect faces in webcam video. When a face is detected, its position and size are sent over serial to an Arduino, which controls motors on a chassis to move the bot and keep the face centered in the webcam view. The hardware includes an Arduino, chassis, webcam, and motor driver. The algorithm detects faces using OpenCV and directs the bot's movement based on face position data.

Uploaded by

Sixsigma Tqm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Face Detection and Tracking With Arduino

and OpenCV
#include <Servo.h> //Used to control the Pan/Tilt Servos

//These are variables that hold the servo IDs.


char tiltChannel=0, panChannel=1;

//These are the objects for each servo.


Servo servoTilt, servoPan;

//This is a character that will hold data from the Serial port.
char serialChar=0;

void setup(){
servoTilt.attach(2); //The Tilt servo is attached to pin 2.
servoPan.attach(3); //The Pan servo is attached to pin 3.
servoTilt.write(90); //Initially put the servos both
servoPan.write(90); //at 90 degress.

Serial.begin(57600); //Set up a serial connection for 57600 bps.


}

void loop(){
while(Serial.available() <=0); //Wait for a character on the serial
port.
serialChar = Serial.read(); //Copy the character from the serial port
to the variable
if(serialChar == tiltChannel){ //Check to see if the character is the
servo ID for the tilt servo
while(Serial.available() <=0); //Wait for the second command byte from
the serial port.
servoTilt.write(Serial.read()); //Set the tilt servo position to the
value of the second command byte received on the serial port
}
else if(serialChar == panChannel){ //Check to see if the initial serial
character was the servo ID for the pan servo.
while(Serial.available() <= 0); //Wait for the second command byte
from the serial port.
servoPan.write(Serial.read()); //Set the pan servo position to the
value of the second command byte received from the serial port.
}
//If the character is not the pan or tilt servo ID, it is ignored.
}
}
Arduino-OpenCV-Human-Follower
1. Dependencies
2. Hardware
3. Setup and Algorithm

Dependencies

 PySerial
 OpenCV for Python

Hardware

 Arduino Uno
 Chassis
 webcam
 motor driver

The assembled chassis with webcam looks like this.

Setup and Algorithm

The project uses OpenCV library with python for building an algorithm to detect humans by
tracking faces. The hardware is based on Arduino microcontroller and an external webcam
connected via an intermediate personal computer where all the image processing takes place.
Both the Arduino and the webcam are mounted on a chassis.

Based on the position and size of the face detected, signals from the computer are serially
communicated to the Arduino which in turn controls the bot to move accordingly to keep
tracking the human face

You might also like