IP Camera With Face Detection Using the ESP32-CAM Board

About: #BnBe is a platform to help teach electronics no matter what the age or skill level. We’re currently designing a wide range of products from beginner level kits to industry-standard microcontroller platforms.

This post is different compared to the others and we take a look at the very interesting ESP32-CAM board that is surprisingly cheap (less than $9) and easy to use. We create a simple IP camera that can be used to stream a live video feed using the 2MP camera module. We also try out the face detection and face recognition feature.

The video above covers everything you need in under 4 minutes.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Configure the Arduino IDE

We start by adding the ESP32 board support package to the Arduino IDE. The following links contain a detailed overview of what needs to be done:

Windows: https://www.bitsnblobs.com/esp32-cam-getting-star...

Mac: https://www.bitsnblobs.com/esp32-cam-getting-star...

In summary, you need to add the following link to the boards manager URL from the File menu.

https://dl.espressif.com/dl/package_esp32_index.json

Then, open up the boards manager, search for ESP32 and install the package. Wait for it to complete and close the window. Make sure you have selected the right board settings from the tools menu, as seen in the image. The COM port will not be available until you carry out the next step.

Step 2: Wire Up the Board

The ESP32-CAM board does not have an onboard USB connector so you need to use an external USB to serial converter to upload the sketch. You can use the wiring connections shown above but make sure that the USB to serial converter is connected in the 3.3V mode.

It is recommended to use an external 5V supply to power the board, particularly if you are using an FTDI breakout board. For the external 5V supply, a simple USB breakout board will do just fine. There has been some success in powering the board directly from the CP2102 breakout board so you can try that first. The board also has a 3.3V power pin if needed.

The jumper is needed to put the board in the download mode. Once you have everything connected, power up the board, open a serial terminal (Tools->Serial Monitor) with a baud rate of 115,200 and press the reset button. You should obtain an output as shown in the image and this will indicate that everything is working as expected.

Step 3: Prepare the Sketch

Open up the CameraWebServer example sketch as shown in the image above. Make sure you add your WiFi network name and password as the board will have to connect to it. Also, be sure to select the AI_THINKER camera model as seen in the image. One this is done. Upload the sketch and then open the serial monitor again.

Give the board a few seconds to connect to the WiFi network and you will then see the connection status along with the IP address. Keep a note of this as we move to the next step.

Step 4: View Camera Stream

Open up a web browser and enter the IP address that was obtained in the previous step. You should obtain a page like the one in the image. Click the "START STREAM" button and you should be able to view the live stream. You change the resolution to something higher, depending on your needs. There are also a few settings and effects that you can play around with.

If you do get horizontal lines in the video feed, then this is an indication of insufficient power. Try using a shorter USB cable or an alternate power source in that case.

You can also obtain a still image, but since this is not stored anywhere, you will have to right-click and save it if required.

Step 5: Face Detection & Recognition

In order for face detection to work, you would need to select a CIF or lower resolution. The board will process the video feed to detect a face and highlight it on screen. If you enable face recognition, then it will check to see if the face that is detected is known or enrolled, if not, it will tag it as an intruder. If you want to save a face then you can hit the enrol face button to register multiple samples that it will use as a reference.

That’s how easy it is to build a simple IP camera using the ESP32-CAM. The video quality is not excellent but they have really simplified the whole process of working with camera modules like this. We will use this to create some more interesting projects so if you've liked this one, then don't forget to follow us using the links below:

Be the First to Share

    Recommendations

    • Instrument Contest

      Instrument Contest
    • Make it Glow Contest

      Make it Glow Contest
    • STEM Contest

      STEM Contest

    2 Discussions