[PYTHON] I made a simple network camera by combining ESP32-CAM and RTSP.

I made a simple network camera using ESP32-CAM and RTSP.

Reasons for using RTSP

The ESP32-CAM can be developed using the Arduino IDE as well as the ESP32. A sket called "Camera Server" is prepared as a sample, and you can easily use it as a network camera by writing it to the ESP32-CAM.

After writing, you can watch the video by accessing the IP address assigned to the ESP32-CAM from a browser. In addition, image quality adjustment and face detection can be operated from the browser, which is sufficient for a simple network camera.

This time, I made a network camera using RTSP without using it. The biggest reason for this was that my goal was to "make video available / available in Python programs."

Precautions when using ESP32-CAM

The ESP32-CAM has WiFi and Bluetooth capabilities. To use this function in Japan, it is necessary to obtain "Technical Conformity" from the Ministry of Internal Affairs and Communications. Using products that have not acquired technical suitability may be subject to penalties.

See here for details [Wikipedia: Technical suitability mark](https://ja.wikipedia.org/wiki/%E6%8A%80%E9%81%A9%E3%83%9E%E3%83%BC%E3%82%AF #% E6% A6% 82% E8% A6% 81) Wireless standard certification system About the standard certification system for terminal devices

From November 20, 2019, a system has started that allows you to use equipment that has not acquired technical suitability for experiments. Special system for experiments using equipment that has not acquired technical suitability

Under this system, you will be able to use the unacquired technical suitability for experimental purposes by submitting a prescribed notification. However, there are certain restrictions such as the period, available wireless standards, and frequency bands.

This time, I made this notification and am using ESP32-CAM.

Sketch of ESP32-CAM

When using RTSP with ESP32-CAM this time, I referred to the following repository. Micro-RTSP

Changes from the original sketch

The original sketch used the ESP32-CAM in SoftAP mode (access point mode). I changed it and set a fixed IP address.

wsp32-cam.ino



WiFi.config(ip, gatway, subnet);
while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    WiFi.begin(ssid, password);

    delay(10000);
  }

Also, in the original sketch, Web Server was set in addition to RTSP, but it was deleted for the sake of simplification of the sketch.

Processing on the Python side

In Python, the video from ESP32-CAM is received and displayed by OpenCV.

view.py


esp_ip = ''
esp32cam_camera = cv2.VideoCapture(f"rtsp://{esp_ip}:8554/mjpeg/1")

Since it can be handled simply as image data on the Python side, it can be used in various ways such as face recognition and object recognition.

The created source is uploaded to git. ESP32CAM_RTSP

Recommended Posts

I made a simple network camera by combining ESP32-CAM and RTSP.
I made a simple circuit with Python (AND, OR, NOR, etc.)
I made a simple blackjack with Python
I made a network to convert black and white images to color images (pix2pix)
I made a simple Bitcoin wallet with pycoin
Create a layout by combining Dash and Bootstrap
I made a simple RSS reader ~ C edition ~
〇✕ I made a game
I made a LINE BOT with Python and Heroku
I made a simple typing game with tkinter in Python
I scraped the Organization member team and made a ranking
A simple interactive music player made with Chuck and OpenPose
I made a simple book application with python + Flask ~ Introduction ~
I made a surveillance camera with my first Raspberry PI.
I made a Chatbot using LINE Messaging API and Python
I made a neural network generator that runs on FPGA
I made a python text
I made a discord bot
I tried to create a simple credit score by logistic regression.
I made a game called Battle Ship using pygame and tkinter
I made a Nyanko tweet form with Python, Flask and Heroku
Simple network operation by linking Cisco DNA Center and Tact Switch
I made a Twitter bot that mutters Pokemon caught by #PokemonGO
I made RNN learn a sine wave and made a prediction: Hyperparameter adjustment
[Python] I made an image viewer with a simple sorting function.
I made a Discord chat reading bot by imitating the appearance
I made a Chatbot using LINE Messaging API and Python (2) ~ Server ~
I made a chatbot with Tensor2Tensor and this time it worked
I made a C ++ learning site
I made a Line-bot using Python!
I made a CUI-based translation script (2)
I made a wikipedia gacha bot
I made a fortune with Python.
I made a CUI-based translation script
I implemented a two-layer neural network
Simple neural network theory and implementation
I made a daemon with Python
I made a kind of simple image processing tool in Go language.
I made a program to notify you by LINE when switches arrive
I made a simple timer that can be started from the terminal
I made a program to input what I ate and display calories and sugar
I made an image discrimination (cifar10) model using a convolutional neural network.
A super introduction to Django by Python beginners! Part 5 I made a super simple diary application with a class-based general-purpose view