Sunday, April 21, 2024

Artificial Intelligence Drone With Real Time Face Recognition, Traffic Monitoring

What If I say now Drones can find criminals and use AI to detect the face of criminals help gov to find criminals, lost people. Yes, It’s true you can now make own drone at a very low cost that is capable of doing all these stuff of its own and help the government to find the people and criminals, terrorist, find the bunkers and any more things in very low cost and at very effective way. You can make this by yourself. So here we develop and design a AI drone that we can fly and we equip it with SOC like RPi 4/ Balena fin running the image processing code independently without affecting the flight controller and detect the people and recognize the face and find the criminals..We make a drone with an F450 frame using the 1000kv Motor. 

First of all we need to collect the following components to make our drones.

Bill Of Material


In Addition of this you might also need Xt60 or any other connector as per your battery.

Construction and Assembly

We have already made and constructed the simple F450 drone and you can construct the drone using the article –>F450 Drone with KK.2.2 Flight controller 

- Advertisement -

Assuming you have already constructed the drone using our previous article now we lets jump into Drone AI part

Making Drone Smart Using AI and Face Recognition 

At first, I tried mounting the Drone with RPi Compute Module and Balena fin having 1GB of ram and 16 GB of storage, and as the Balena fin take 12V dc so it’s easy to power it with Lipo battery but the problem I faced it is it is little heavy and large to mount on Drone. Then I realized that RP4 takes 2A and 5 Volt of current that can also be power by one of the Linear  ESC that I am using with Motor.

So here I have switched the Blaenafon with the Small RPi 4.

- Advertisement -

Mounting the Rpi 4 and Camera On F450 Frame

Now for face recognition we mount the Rpi Camera on drone frame and fix it with insulation tape or Zipper then we cut the +ve and -Ve wire of one of ESC that is connected to the flight controller as Flight controller board usages only first ESC Pins to Power it self and rest ESC powering pins are free so we use it to power the Raspberry Pi.

Ai drone construction
Fig 1. Raspberry Pi power input

Next we mount the camera moule of RPi on the Drone as in pic below .

Fig 2. Attaching camera
Camera mounted on AI drone
Fig 3. Camera mounted on AI drone

Coding the drone for Face Recognition 

This is to recognize the person in front of the robot (known or unknown). In this code, we will import 3 modules: face recognition, cv2 and numpy. We will create different arrays for recognising faces and names. Make sure to write the image file name of that member for correct face recognition. (Refer fig 4 and 5).

Face recognition code
Fig 4. Face recognition code
Fig 5. Names of person to recognise

In the next part of code, we will try to match the face that has been captured by the camera with the array of known faces. If the face matches, then the code will run the espeak synthesizer to speak the person’s name using the syntax ‘espeak.synth ()’ as in the pic below to do announcement like hey you are cathed , please drop your gun, or the criminal find or any thing that you want to say drone on finding that person.

Fig 6.

Next connect the pam amplifier as below connection diagram and power the pam ampligert using GPIO pin 5v and GND of Rpi 4.

AI Drone Connection
Fig 7. AI Drone Connection

Person Detection to Find Stucked One in Flood & Earthquake  

Now we create the code for the people detection so that the drone camera can able to take live footage in flood and  detect the people find the number of people stuck in flood 

Firstly, install the following libraries in Python.

  • Espeak
  • Numpy
  • Scipy
  • Opencv
  • Dlib
  • Keras
  • TensorFlow/TensorFlow Lite

To install the above libraries, open the LX terminal and then type the following commands: 

sudo  apt-get update

sudo apt-get upgrade

sudo nano /etc/dphys-swapfile

Then change the line CONF_SWAPSIZE=100 to  CONF_SWAPSIZE=1024

sudo /etc/init.d/dphys-swapfile stop  

sudo /etc/init.d/dphys-swapfile start

sudo pip3 install opencv

sudo pip3 install numpy


pip3 install dlib

pip3 install tensorflow

After the installation you can now proceed with the cloning of TF modules and examples and files using the following command: 

git clone  

After successfully cloning, go to the directory →  research folder → create a new Python file and paste the code attached with the article. 


For Crowd detection and traffic monitoring we need to so some presutup before coding , First presetup is making a special .pbtxt file that contain the name of thing to detect here we want our drone to detect is people so we got Tensorflow–>models–>research->object detection–>data folder  then we create one file name crowd.pbtxt and then we insert only people in the list to detect and then one more file with traffic.pbtxt with list of object to detect for traffic like car, bus, people, sign board , truck etc as in(Fig 8,9,10)

Now In the first part of the code, we have to initialize the required library. Then we will have the code that uses the camera module to take live video and then process it frame-by-frame to detect the people. So here as you can see in the code snippet we have imported the required library code.

Next we have to define the .pbtxt file name that we have created earlier that has the list of objects to detect. After that we have created the substring that checks the number of people string come in the detected output string so that it can estimate the number of people and the availability of people in the image and then it will detect the number of people and tell us. We will do the same for the traffic monitoring as we we only need to change .pbtxt file in code with traffic.pbtxt file to detect the car , bus etc on road and count them.

NOTE:- We also do the forest survey and animal detection with same code we only need to change the .pbtxt file and create a file with list of animals to be detected and then in substring we will change the string name to find in output results.

Fig 9.
Fig 10. Setting .pbtxt
Fig 11.
Fig 12.Detecting traffic
Fig 13. Detecting people/ crowd


You need to run each code (drone-,, and dron- separately at different times for different applications. For example, when the is up and running, mount it on the drone. You can see live images being captured by the camera on your com- puter screen. You can send the drone with camera to a designated area for detection and monitoring. The dis- tance the drone can fly depends on the Wi-Fi range.

AI Drone recognizing face
Fig 14. AI Drone recognizing face
AI Drone detecting people and traffic
Fig 15. AI Drone detecting people and traffic

Download Source Code

Ashwini Sinha
Ashwini Sinha
A tech journalist at EFY, with hands-on expertise in electronics DIY. He has an extraordinary passion for AI, IoT, and electronics. Holder of two design records and two times winner of US-China Makers Award.


  1. Can I get the whole kit by paying the amount as I am in a location where the feasibility of getting the list of items is very difficult. Would be a great help if you can assist with the same.


Unique DIY Projects

Electronics News

Truly Innovative Tech

MOst Popular Videos

Electronics Components