This is a basic project to demonstrate a face detection and tracking system using python and opencv on a jetson nano developement board.
- Hardware requirements.
- Software requirements.
- A jetson nano developement kit
- Two raspberry pi v2 8MP camera.
- A stereo camera actuator system.
Here we are using jetson nano developement board as master computer and two raspberry pi v2 camera for capturing images. We can connect two CSI camera to jetson nano b01, since it support two CSI camera port.
The next important part is the servo assisted stereo camera holder to achive pan and tilt movement of the camera. For this we will be using the "Stereo_Camera_Actuator" system. Please refer this repository https://github.com/asujaykk/Stereo_Camera_Actuator to build one.
First boot your jetson nano developement board with latest JDK. Then we need to install the following modules and libraries.
-
First clone this repository to your working directory.
git clone https://github.com/asujaykk/Face-detection-and-tracking.git
-
Camera module : To read images from two cameras. Add Camera module to "Face-detection-and-tracking" folder.
cd Face-detection-and-tracking git clone https://github.com/asujaykk/Camera.git
-
Serial module : To send command to Stereo_Camera_Actuator for changing camera angle. Serial module need to be installed in your PC using below command
pip3 install pyserial
-
OpenCv library : For detecting and tracking face in the image. Opencv is pre installed in jetson SDK. So no need to install it explicitly.
First connect 'Stereo_Camera_System' (arduino board) to jetson nano via usb cable.
Connect LEFT camera to CAM0 CSI port.
Connect RIGHT camera to CAM1 CSI port.
-
Open terminal and navigate to your working directory
-
Open Face-detection-and-tracking directory:
cd Face-detection-and-tracking
-
Run the following command to start face tracking process.
python3 face_tracker.py
If you are getting permission error with serial port, then please run below command .
sudo chmod 666 /dev/ttyACM0
Also restart the 'nvargus-daemon' with below command. to release the two camera instances which was not closed properly in the first run.
sudo systemctl restart nvargus-daemon
Then again run 'python3 face_tracker.py'
-
If the system is working fine, then you will receive the folloing messages on the terminal.
SCA initializing...
SCA initialized.After this message, two camera stream window will appear (one for left camera and another for right camera). If there is any face detected in the frame, then the overall system will continously track that face until the face leave the visible range of the camera.
-
The following GIF shows the output of the detection and tracking system.