6
Documentation -- Face Tracking (Hong YU) Introduction What I wanted to make was an auto-camera, which can detect my face, tracking my face, then take pictures or videos of me and send to my mom automatically. Here I made in this 8-weeks course is the first and main part of this auto-camera. In this project I have assembled a face detection and tracking system. You can see the video of the final project attached. Basically, the webcam sends video frames to OpenCV running on a Windows PC. If OpenCV detects a face it will track it and calculate its center's X,Y coordinates. The coordinates are then passed on to the Arduino via a serial USB connection. The Arduino controls the movement of the webcam with the help of two pan/tilt servos to follow the detected face. The final vision of my small project of face tracking is like the picture below. List of materials Software required: - Arduino IDE 1.0.6 for Windows. - OpenCV 2.3.1 SuperPack for Windows.

Documentation -- Face Tracking (Hong YU) · Documentation -- Face Tracking (Hong YU) Introduction What I wanted to make was an auto-camera, which can detect my face, tracking my face,

  • Upload
    others

  • View
    15

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Documentation -- Face Tracking (Hong YU) · Documentation -- Face Tracking (Hong YU) Introduction What I wanted to make was an auto-camera, which can detect my face, tracking my face,

Documentation

-- Face Tracking (Hong YU)

Introduction

What I wanted to make was an auto-camera, which can detect my face, tracking my

face, then take pictures or videos of me and send to my mom automatically. Here I

made in this 8-weeks course is the first and main part of this auto-camera.

In this project I have assembled a face detection and tracking system. You can see the

video of the final project attached.

Basically, the webcam sends video frames to OpenCV running on a Windows PC. If

OpenCV detects a face it will track it and calculate its center's X,Y coordinates. The

coordinates are then passed on to the Arduino via a serial USB connection. The

Arduino controls the movement of the webcam with the help of two pan/tilt servos to

follow the detected face.

The final vision of my small project of face tracking is like the picture below.

List of materials

Software required:

- Arduino IDE 1.0.6 for Windows.

- OpenCV 2.3.1 SuperPack for Windows.

Page 2: Documentation -- Face Tracking (Hong YU) · Documentation -- Face Tracking (Hong YU) Introduction What I wanted to make was an auto-camera, which can detect my face, tracking my face,

- Microsoft Visual Studio 2010 Ultimate.

Code Required

- OpenCV's example facedetect.cpp.

- Ryan Owens' example SerialServoControl.pde.

Hardware Required

- PC preferably running Windows 7 SP1. The faster CPU the better.

- Arduino uno.

- 2 Servo Motor.

- Webcam.

- Jumper wires.

- Hobby wire and tape to tie pan/tilt servos and webcam together.

Working Process

1.Installation and integration issues

1) Download and install the OpenCV-2.3.1-win-superpack.exe. Everything I need

from OpenCV to build this project has already been generated in this download.

2) Download and install Microsoft Visual Studio 2010 Ultimate.

3) Set the environment for OpenCV.

The OpenCV installation documentation explains how to make Visual C++ aware of

the OpenCV support files (include, bin, etc). This is not a one-click job. Careful

attention must be given to how Visual C++ must be configured to recognize OpenCV

files.

Page 3: Documentation -- Face Tracking (Hong YU) · Documentation -- Face Tracking (Hong YU) Introduction What I wanted to make was an auto-camera, which can detect my face, tracking my face,

2. Change Codes

Change the C++ code to match the PC's com port and baud rate with Arduino's. Also,

the C++ code must be told which USB port the webcam is using.

3.Wiring the parts together

Page 4: Documentation -- Face Tracking (Hong YU) · Documentation -- Face Tracking (Hong YU) Introduction What I wanted to make was an auto-camera, which can detect my face, tracking my face,

SERVOS:

The white/signal wire for the pan (X axis) servo goes to digital pin 9.

The white/signal wire for the tilt (y axis) servo goes to digital pin 10.

The red/Vcc wires of both servos go to the Arduino's 5V pin.

The black/GND wires of both servos go to Arduino's GND pin.

WEBCAM

The webcam's USB goes to the PC. The C++ code will identify it via a number

representing the USB port its connected to.

ARDUINO

The Arduino Uno is connected to the PC via USB. Take note of the COM port the

USB is connected to. You can find the com port from the Arduino Tools/Serial Ports

menu.

4. Attach servos and camera

I did not want to affix any of the project parts permanently because I like to take my

projects apart after I am done, and I did not have time to use 3D printer to make

something to fix them. So I used hobby wire, which is nothing more than a stiff wire,

to tie the servos and the webcam together. I wrapped the base of the webcam to the

pan servo horn. Then I wrapped a cable around the horn of the tilt servo and the body

of the pan servo. To keep the whole servo/webcam assembly from moving randomly

during operation, I used tape to tie it to the box. It kept is steady during servo rotation.

Screenshots of Working

Page 5: Documentation -- Face Tracking (Hong YU) · Documentation -- Face Tracking (Hong YU) Introduction What I wanted to make was an auto-camera, which can detect my face, tracking my face,
Page 6: Documentation -- Face Tracking (Hong YU) · Documentation -- Face Tracking (Hong YU) Introduction What I wanted to make was an auto-camera, which can detect my face, tracking my face,

Difficulties

There are 2 big difficulties I met during my project.

1) Set the environment for OpenCV

To make the C++ code recognize the OpenCV, I followed the document of OpenCV to

set some basic things, but work was not done. Because OpenCV 2.3.1 and Visual

Studio 2010 was for systems that are 32 bits, but my computer is 64 bits. So I

searched and found some examples about match them with 64-bits system. And

changed both in the setting of my computer and Visual Studio. After a few nights

working, it finally worked!

2) Servo Motor

When I finally worked out the OpenCV part, I found that servo motors do not move

frequently. They sometimes can follow with my face, but sometimes not, or move

very slowly. First I used the example in Arduino to check my servos, and find there

are nothing wrong with them. Then I changed some values in the code of Arduino but

did not work well either. Romain suggested checking the connection of servos, so I

welded the wires of the servos with the jumper wires. Then, magically, it worked.