Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » ESP32 CAM Based Face & Eyes Recognition System
ESP32-CAM Projects IoT Projects

ESP32 CAM Based Face & Eyes Recognition System

Priyansh ShankhdharBy Priyansh ShankhdharUpdated:May 29, 20237 Comments6 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
ESP32 CAM Face Recognition System
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview: ESP32 CAM Face Recognition System

In this project, we will build an ESP32 CAM Based Face & Eyes Recognition System. This tutorial introduces everyone to an efficient video streaming method wirelessly. Here we have used the ESP32-CAM module, which is a small camera module with the ESP32-S chip. Besides the OV2640 camera and several GPIOs to connect peripherals, it also features a microSD card slot that can be useful to store images taken with the camera.

We will go through ESP32 CAM features, pins description, and the method to program this device using FTDI Module. Then we will install the ESP32 CAM Webserver Library & upload the example Code using Arduino IDE. Apart from this, we will also install the required Python Libraries. Later we will go through the python code for Face & Eyes Recognition.

This is an essential tutorial as you will be able to use any sort of Image processing or Machine Learning on the live video without having to write it on Arduino IDE.



Bill of Materials

The following is the list of Bill of Materials for building an ESP32 CAM Based Face & Eyes Recognition System. You can purchase all these components from Amazon.

S.N.ComponentsQuantityPurchase Links
1ESP32-CAM Board AI-Thinker1Amazon | AliExpress
2FTDI Module1Amazon | AliExpress
3Micro-USB Cable1Amazon | AliExpress
4Jumper Wires10Amazon | AliExpress

ESP32 CAM Module

The ESP32 Based Camera Module developed by AI-Thinker. The controller is based on a 32-bit CPU & has a combined Wi-Fi + Bluetooth/BLE Chip. It has a built-in 520 KB SRAM with an external 4M PSRAM. Its GPIO Pins have support like UART, SPI, I2C, PWM, ADC, and DAC.

The module combines with the OV2640 Camera Module which has the highest Camera Resolution up to 1600 × 1200. The camera connects to the ESP32 CAM Board using a 24 pins gold plated connector. The board supports an SD Card of up to 4GB. The SD Card stores capture images.

To learn in detail about the ESP32 Camera Module you can refer to our previous Getting Started Tutorial.


ESP32-CAM FTDI Connection

The board doesn’t have a programmer chip. So In order to program this board, you can use any type of USB-to-TTL Module. There are so many FTDI Module available based on CP2102 or CP2104 Chip or any other chip.

Make a following connection between FTDI Module and ESP32 CAM module.

ESP32 CAM FTDI Module Connection

ESP32-CAMFTDI Programmer
GNDGND
5VVCC (5V)
U0RTX
U0TRX
GPIO 0GND

Connect the 5V & GND Pin of ESP32 to 5V & GND of FTDI Module. Similarly, connect the Rx to UOT and Tx to UOR Pin. And the most important thing, you need to short the IO0 and GND Pin together. This is to put the device in programming mode. Once programming is done you can remove it.




Project PCB Gerber File & PCB Ordering Online

If you don’t want to assemble the circuit on a breadboard and you want PCB for the project, then here is the PCB for you. The PCB Board for ESP32 CAM Board is designed using EasyEDA online Circuit Schematics & PCB designing tool. The PCB looks something like below.

ESP32 Cam Board PCB

The Gerber File for the PCB is given below. You can simply download the Gerber File and order the PCB from ALLPCB at 1$ only.

Download Gerber File: ESP32-CAM Multipurpose PCB

You can use this Gerber file to order high quality PCB for this project. To do that visit the ALLPCB official website by clicking here: https://www.allpcb.com/.

You can now upload the Gerber File by choosing the Quote Now option. From these options, you can choose the Material Type, Dimensions, Quantity, Thickness, Solder Mask Color and other required parameters.

After filling all details, select your country and shipping method. Finally you can place the order.

You can assemble the components on the PCB Board.


Installing ESP32CAM Library

Here we will not use the general ESP webserver example rather another streaming process. Therefore we need to add another ESPCAM library. The esp32cam library provides an object oriented API to use OV2640 camera on ESP32 microcontroller. It is a wrapper of esp32-camera library.

Go to the following Github Link and download the zip library as in the image

Once downloaded add this zip library to Arduino Libray Folder. To do so follow the following steps:
Open Arduino -> Sketch -> Include Library -> Add .ZIP Library… -> Navigate to downloaded zip file -> add


Arduino Source Code/program

The source code/program ESP32 CAM Face Recognition can be found in Library Example. So go to Files -> Examples -> esp32cam -> WifiCam.

You need to change your WiFi SSID and Password.

1
2
const char* ssid = "*********";
const char* password = "*********";

Now go to tools. Then select the ESP32 Board. And from the list select ESP32Wroover Module.

Then connect the FTDI Module to your Computer and select the COM Port.

ESP32 CAM Getting Started

Now you can upload the code. But while you upload the code the IO0 pin should be shorted with the ground. Once the code is uploaded, remove the shorting Jumper and press the RESET pin.

In the Serial Monitor similar output must be shown.

Copy the IP address visible, we will be using it to edit the URL in python code.


Python Installation & Source Code

For the live stream of video to be visible on our computer we need to write a Python script that will enable us to retrieve the frames of the video. The first step is to install Python. Go to python.org and download Python.

Install Python once downloading is completed.
Then Go to the command prompt and install NumPy and OpenCV libraries.

  • type: pip install numpy and press enter. After the installation is done.
  • type: pip install opencv-python and press enter, close the command prompt.

Now open Idle code editor or any python code editor and paste the following code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import cv2
import urllib.request
import numpy as np
f_cas= cv2.CascadeClassifier(cv2.data.haarcascades+'haarcascade_frontalface_default.xml')
eye_cascade=cv2.CascadeClassifier(cv2.data.haarcascades +'haarcascade_eye.xml')
url='http://192.168.1.58/cam-lo.jpg'
##'''cam.bmp / cam-lo.jpg /cam-hi.jpg / cam.mjpeg '''
cv2.namedWindow("Live Transmission", cv2.WINDOW_AUTOSIZE)
while True:
    img_resp=urllib.request.urlopen(url)
    imgnp=np.array(bytearray(img_resp.read()),dtype=np.uint8)
    img=cv2.imdecode(imgnp,-1)
    gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
    face=f_cas.detectMultiScale(gray,scaleFactor=1.1,minNeighbors=5)
    for x,y,w,h in face:
        cv2.rectangle(img,(x,y),(x+w,y+h),(0,0,255),3)
        roi_gray = gray[y:y+h, x:x+w]
        roi_color = img[y:y+h, x:x+w]
        eyes = eye_cascade.detectMultiScale(roi_gray)
        for (ex,ey,ew,eh) in eyes:
            cv2.rectangle(roi_color,(ex,ey),(ex+ew,ey+eh),(0,255,0),2)
    cv2.imshow("live transmission",img)
    key=cv2.waitKey(5)
    if key==ord('q'):
        break
 
cv2.destroyAllWindows()

Change the IP address copied from Arduino serial monitor and update it in the URL variable in the above code. Then save it and RUN.



ESP32 CAM Face Recognition System

After you run the code, a pop-up window with the name “Live Transmission” appears, showing the live video.

ESP32 CAM Face Recognition System

red-colored rectangular box covering the whole face and within that if it recognizes eyes. Then green colored boxes appear around the eyes.

For the high resolution of live video transmission, change the URL variable in python code by replacing it with url=’http://192.168.1.58/cam-hi.jpg‘.

Save and run the code again.


Benifits of Face Recognition System

The major benefit of this method is, most of our algorithms that involve any processing on images are very heavy to implement on microcontrollers and require more processing, thus making the whole system slow.

Instead, we can implement the difficult and high processing tasks on our computer such as Image processing or Artificial Neural network, etc.


Video Tutorial & Guide

ESP32 CAM Based Face & Eyes Recognition System using OpenCV
Watch this video on YouTube.

We also developed a system where we implemented Color Detection System using ESP32 CAM & OpenCV.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleHow to use TM1637 4-digit 7-segment LED display with Arduino
Next Article How To Program Raw ESP8266-12E/F Chip using Arduino IDE

Related Posts

IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

Updated:May 10, 20261K
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

Updated:May 2, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

Updated:April 27, 20261K
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

Updated:April 27, 20262K
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

Updated:February 1, 20261K
View 7 Comments

7 Comments

  1. Sword on October 1, 2021 11:47 PM

    Is it possible to enroll faces and save them locally?

    I’d like to be able to create a security system and enroll faces accordingly.

    Reply
  2. Sparius on May 7, 2022 11:19 AM

    Hello Priyanesh,

    Nice project, but I had some problems although I followed the instructions exactly.
    I also installed the library fron GitHub
    -The first problem is the file WifiCam, your WifiCam file is different from the one in my Arduino IDE 1.8.2
    -The second problem is I got the following message during compiling.

    /home/itsme/Arduino/libraries/esp32cam-main/src/esp32cam.cpp: In member function ‘esp32cam::ResolutionList esp32cam::CameraClass::listResolutions() const’:
    /home/itsme/Arduino/libraries/esp32cam-main/src/esp32cam.cpp:30:3: error: ‘camera_sensor_info_t’ was not declared in this scope
    camera_sensor_info_t* info = esp_camera_sensor_get_info(&sensor->id);
    ^
    /home/itsme/Arduino/libraries/esp32cam-main/src/esp32cam.cpp:30:25: error: ‘info’ was not declared in this scope
    camera_sensor_info_t* info = esp_camera_sensor_get_info(&sensor->id);
    ^
    /home/itsme/Arduino/libraries/esp32cam-main/src/esp32cam.cpp:30:70: error: ‘esp_camera_sensor_get_info’ was not declared in this scope
    camera_sensor_info_t* info = esp_camera_sensor_get_info(&sensor->id);

    Question;
    Do you have a solution for the above error ?
    Or some other hints or ideas ?

    Thanks in advance, Sparius

    Reply
  3. Sparius on June 23, 2022 3:06 PM

    Nice project !

    While compiling it gives the following error message:

    uri/UriBraces.h: No such file or directory

    Where can I find this ?

    Reply
  4. wIWa on July 18, 2022 9:02 PM

    The 5V-Powerconnector of the pcb is faulty. It makes a shortcut

    Reply
  5. Axel on September 8, 2022 2:03 AM

    Do you know why when I added my IP to python program it shows the error:

    urllib.error.HTTPError: HTTP Error 404: Not Found

    I checked the ip in my browser and the camera is working well, but not when I run the Python Module

    Reply
  6. Alex on December 16, 2022 3:23 PM

    When I add the IP address to the Python code on the website and run the code, I get the error urllib.error.HTTPError: HTTP Error 404: Not Found. Can anyone help me?

    Reply
  7. Javier Bohorquez on December 19, 2022 9:54 AM

    the URL o the image its wrong, enter in the IP of te ESP CAM and select the correct URL as this: http://192.168.0.12/1600×1200.jpg

    Reply

CommentsCancel reply

Latest Posts
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

May 31, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

February 1, 2026
Top Posts & Pages
  • How to use INA226 DC Current Sensor with Arduino
    How to use INA226 DC Current Sensor with Arduino
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
  • IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
    IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • Boost Converter: Basics, Working, Design & Application
    Boost Converter: Basics, Working, Design & Application
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (204)
    • ESP32 MicroPython (7)
    • ESP32 Projects (81)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.