An open API service indexing awesome lists of open source software.

https://github.com/iammi/handcap-edge

Embeded competition ---- Edge
https://github.com/iammi/handcap-edge

cpp embedded-systems

Last synced: 12 months ago
JSON representation

Embeded competition ---- Edge

Awesome Lists containing this project

README

          

# ๐Ÿ“น Embedded YOLO-Based RTMP Streaming System
This project is a lightweight real-time video stream detection and streaming system deployed on the Loongson embedded development board, featuring:
- Capturing camera frames using V4L2 (MJPEG format)
- Decoding to BGR images using OpenCV
- Detecting human presence using YOLOv5
- Triggering detection every few frames and sending alerts via HTTP POST upon detection
- Encoding and streaming frames to RTMP server via FFmpeg

## ๐Ÿงฉ System Architecture
```text
[Camera (/dev/video0)] --> [V4L2 + OpenCV decoding] --> [YOLOv5 detection thread]
| |
|-----> RTMP stream via FFmpeg ----------------|
|-----> Alert system (curl POST JSON to server)|
```
## ๐Ÿš€ Features
- ๐ŸŽฅ **MJPEG camera** frame capture
- ๐Ÿค– Lightweight **YOLOv5-based** human detection
- ๐ŸŒ Send alert events to remote server using **curl**
- ๐Ÿ“ก Real-time streaming (RTMP via **FFmpeg** subprocess)
- ๐Ÿงต **Multithreaded** architecture with **condition variable** synchronization
- ๐Ÿ–ฅ๏ธ Compatible with embedded Linux (e.g., **Loongson** platform)

## ๐Ÿ“ฆ Build Dependencies
- C++17 or later
- OpenCV
- FFmpeg (must be available via CLI)
- libcurl
- V4L2 (included in Linux kernel)

## ๐Ÿ”ง Usage
1. Prepare the camera device
Make sure the device `/dev/video0` is accessible and supports MJPEG format.

> If the device `/dev/video0` is not recognized after connecting the camera, it may be due to missing drivers in your board's Linux system. In that case, a kernel replacement might be necessary.

2. Create your own server like aliyun, expose its IP and some ports and rewrite
```C++
const std::string RTMP_LIVE = "rtmp://Your server IP:Port1/stream1";
```
and
```C++
const std::string alertUrl = "http://Your server IP:Port2/alert";
```

3. Compile the program (*adjust paths as needed*)
```bash ๅคๅˆถ ็ผ–่พ‘
g++ -std=c++17 camera.cpp yolo.cpp \
-I/home/loongson/ncnn/build/install/include/ncnn \
-L/home/loongson/ncnn/build/install/lib \
-L/usr/lib/loongarch64-linux-gnu \
-lncnn -lopencv_core \
-lopencv_highgui -lopencv_videoio \
-lopencv_imgproc -lopencv_imgcodecs \
-lavcodec -lavformat -lavutil -lswscale -fopenmp \
-march=loongarch64 \
-lcurl -o camera
```
4. Run the program
```bash ๅคๅˆถ ็ผ–่พ‘
./camera
```

## โš ๏ธ Alert Mechanism
When a person is detected (every 60 frames), the system sends an alert via the following HTTP interface:

```http ๅคๅˆถ ็ผ–่พ‘
POST http://Your server IP:Port/alert
Content-Type: application/json

{
"event": "person_detected",
"camera": "main_camera"
}
```

## ๐Ÿ“ Project Structure (Partial)
```
.
โ”œโ”€โ”€ camera.cpp # Main program: video capture, multithreading, RTMP streaming
โ”œโ”€โ”€ yolo.hpp # YOLO model interface definitions
โ”œโ”€โ”€ yolo.cpp # YOLO model loading and inference implementation
โ””โ”€โ”€ build/ # Build output directory (optional)

```

## ๐Ÿ“Œ TODO
- [ ] Support multiple camera switching
- [ ] Add image compression and encoding optimization
- [ ] Accelerate YOLO inference with CUDA / NPU