I made a simple network camera using ESP32-CAM and 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."
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.
When using RTSP with ESP32-CAM this time, I referred to the following repository. Micro-RTSP
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.
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