Recam is a real-time video streaming solution that enables high-performance camera streaming from an ESP32-CAM to a Python application over UDP. The project consists of two main components: an ESP32-CAM firmware and a Python library for receiving and processing the video stream.
- Real-time video streaming over UDP
- Bidirectional data communication (5 int16 values in each direction) / need to update can send multiple variable
- Low latency transmission
- Simple API for integration with other Python applications
- Configurable video quality and resolution
- Support for AI-THINKER ESP32-CAM module
- AI-THINKER ESP32-CAM module
- FTDI programmer or similar for uploading firmware
- Arduino IDE with ESP32 board support
- Python 3.6 or later
- Required Python packages:
numpy opencv-python
-
ESP32-CAM Setup
- Install the Arduino IDE
- Add ESP32 board support to Arduino IDE
- Install required libraries:
esp32(board package)WiFiWiFiUdp
- Upload the ESP32-CAM firmware from the
esp32camfolder
-
Python Library Setup
pip install numpy opencv-python
- Open the ESP32-CAM sketch in Arduino IDE
- Configure your network settings:
const char *ssid = "your-network-ap"; const char *password = "your-network-password"; const char *udpAddress = "192.168.10.2"; // Your computer's IP address const int udpPort = 7445;
- Upload the firmware to your ESP32-CAM
Basic example of using the Recam library:
from recam import Recam
import cv2
# Initialize Recam
recam = Recam(7445) # Use same port as configured in ESP32
# Start the receiver
if recam.begin():
try:
while True:
# Get the latest image
img = recam.imageData()
if img is not None:
# Display the image
cv2.imshow("Camera Feed", img)
# Get robot data sent from ESP32
robot_data = recam.getRobotData()
print(f"Received data: {robot_data}")
# Send data back to ESP32 (5 int16 values)
recam.setSendData([0, 0, 0, 0, 0])
# Press 'q' to quit
if cv2.waitKey(1) & 0xFF == ord('q'):
break
finally:
recam.close()
cv2.destroyAllWindows()recam = Recam(port)port: UDP port number (must match ESP32 configuration)
Starts the receiver thread.
- Returns:
bool- True if successfully started
Gets the latest received image.
- Returns:
numpy.ndarrayorNone- OpenCV image format (BGR)
Gets the latest robot data received from ESP32.
- Returns:
list- 5 integers received from ESP32
Sets data to send back to ESP32.
data: list of 5 integers (-32768 to 32767)
Closes the connection and cleans up resources.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Author: Rezier
- YouTube: @REZIER_0
- GitHub: NonStopBle
- Special thanks to all contributors who helped improve this project