IOT

ESP32 Cam Video Streaming and Face Detection with Arduino IDE

In an increasingly digital world, protecting confidential information is becoming more difficult day by day. Passwords or pins are not enough to secure our information. To full-fill, this requirement Biometrics are coming into the picture. Biometrics refers to a person’s unique identity. Finger scan, iris scan, and hand scan face recognition are all distinct biometrics. It’s nearly impossible to tamper with biometrically secured or protected equipment.

This blog will guide you through how to get started with the Arduino and the ESP32 module. With the help of the Arduino IDE, we’ll learn how to set up an ESP32 camera for video streaming and face identification. We’ll also learn about the ESP32 cam board’s specifications and general hardware.

What is face recognition???

Identifying an individual by comparing live capture with the stored record for that person. Here we use ESP-32 CAM for face recognition.

Introduction to ESP32-Cam:

The ESP32-CAM development board is another member of the ESP32 module family. The ESP32-CAM is a small size, low-power consumption camera module based on ESP32.

It is an inexpensive board consisting of an ESP32-S chip, an OV2640 video camera, and a micro-SD card slot that is extremely useful in major IoT applications. It can be used with advanced projects where facial recognition, image tracking, wireless monitoring, and identification are required.

Because the ESP32-CAM lacks a USB port, you’ll need an FTDI programmer to upload code via the U0R and U0T pins (serial pins).

ESP32-CAM Features:

  • The smallest 802.11b/g/n Wi-Fi BT SoC module
  • Low power 32-bit CPU,can also serve the application processor
  • Up to 160MHz clock speed, summary computing power up to 600 DMIPS
  • Built-in 520 KB SRAM, external 4MPSRAM
  • Supports UART/SPI/I2C/PWM/ADC/DAC
  • Support OV2640 and OV7670 cameras, built-in flash lamp
  • Support image WiFI upload
  • Support TF card
  • Supports multiple sleep modes
  • Embedded Lwip and FreeRTOS
  • Supports STA/AP/STA+AP operation mode
  • Support Smart Config/AirKiss technology
  • Support for serial port local and remote firmware upgrades (FOTA)

ESP32-CAM Pinout

The following figure shows the ESP32-CAM pinout (AI-Thinker module).

esp32-cam pinout ai-thinker module

There are three GND pins and two pins for Power: either 3.3V or 5V.

GPIO 1 and GPIO 3 are serial pins. You need these pins to upload code to your board. Additionally, GPIO 0 also plays an important role, since it determines whether the ESP32 is in flashing mode or not. When GPIO 0 is connected to GND, the ESP32 is in flashing mode.

The following pins are internally connected to the microSD card reader:

  • GPIO 14: CLK
  • GPIO 15: CMD
  • GPIO 2: Data 0
  • GPIO 4: Data 1 (also connected to the on-board LED)
  • GPIO 12: Data 2
  • GPIO 13: Data 3

Components Required:

  • ESP32-Cam with OV2640 Camera
  •  FTDI programmer 
  • Data Cable 
  • Jumper wires 

Installing ESP32 in the Arduino IDE

For the installation of ESP32, you need to follow some basic steps.

  • The most basic step is to download the Arduino IDE.
  • After you’ve finished installing the Arduino IDE, go to the Preferences tab and click on the file/preferences. (You can also use the Ctrl+Comma shortcut.)
  • Also, in Additional Board Manager URLs, paste the following URL:

https://dl.espressif.com/dl/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json

  • Go to Tools/Board manager.
  • Search ESP32 in the search bar boards manager.
  • Choose an ESP32-related board, choose the most recent version, then click the Install button.
  • Your board has now been successfully installed.
  • Go to Tools/Boards/ESP32 wrover module after installing the ESP32 board.
  • Select the COM port to which the ESP32 cam is connected under Tools/ Port.
  • Select “Huge APP (3MB No OTA)” from Tools/Partition Scheme.

Circuit Diagram

Connections

ESP32 camFTDI converter
UDRTx
UTDRx
3.3VVCC
GNDGND

While doing this connection, you have to short the pins between UO1 and UO0.

Coding part

  • To code the ESP-32 camera module, complete the following steps:
  • First, choose the ESP32 board from the board menu. Select the ESP32 WROVER module from the drop-down menu.
  • Now open the file with the ESP32 and camera code in it. The path will be as follows:
  • Now, mark the following line as a comment.

#define CAMERA_MODEL_WROVER_KIT // Has PSRAM

  • And uncomment the line

#define CAMERA_MODEL_AI_THINKER // Has PSRAM

  • Your code is now ready to upload to the board after you’ve made these changes to it.
  • Make the board configuration given in the figure below before uploading the code.
  • Select “Huge APP (3 MB No OTA/1MB SPIFFS)” as the partition scheme, and the rest of the options are presented in the image.
  • After that, select the port that is connected to the FTDI module. Your ESP32 camera is now active.
  • Make sure that IO0 and GND are both shorted while uploading the code.
  • Press the upload button now. Remove the connections between the pins IO0 and GND after the code has been successfully uploaded.
  • You may view the URL on the serial monitor by pressing the refresh button once.
  • Copy and paste the same link into your browser. The footage obtained by the ESP32 camera may be seen here.

How to access the Video Streaming Server

Remove the jumper between the IO0 and GND pins after uploading the code to the ESP32. Once you’ve pressed the refresh button, the data will appear in the serial monitor of the Arduino IDE.

It will display information for connecting to Wi-Fi; copy the streaming server address and paste it into the URL field in your browser.

You can see, ESP32 cam is streaming the footage captured by the camera on a web server. You can also take a picture if with the help of the ‘get still’ option. For that, you need to insert an SD card into the device.

ESP32 can also allow detecting a face. All you have to try multiple attempts of enrolling your face with a different angle.Once it is enrolled, it will detect you and someone not enrolled in its database when you come in front of the camera. It will give you an intruder alert.

We are done here. Now you can your video streaming web server up and running with face detection and recognition with ESP32 board and a few lines of code.

Conclusion

I Hope this blog guide you through how to get started with the Arduino and the ESP32 module. With the help of the Arduino IDE, we’ll learn how to set up an ESP32 camera for video streaming and face identification..We ,MATHA ELECTRONICS  will come back with more informative blogs.

Leave a Reply

Your email address will not be published.