The Problem

Deploying AI models to edge devices requires a unified build, runtime, and orchestration layer that works across heterogeneous hardware such as Sophon, Rockchip RKNN, and x86. Existing toolchains scatter model‑import scripts, runtime binaries, and configuration files, making it hard to ship a consistent video‑analytics application to multiple target boards.

What This Does

  • Engine & Console – The repository contains a production‑grade C++ engine (src/) that runs on all supported platforms, plus a lightweight web console in src/console/.
  • Model Import & Orchestration – Scripts in tools/ (e.g., tools/import_model.py) convert ONNX/Yolo weights into platform‑specific binaries and generate JSON scene files that the engine reads at runtime.
  • Video Access & Event Delivery – The engine supports ONVIF and GB28181 discovery (src/video_onvif.cpp, src/video_gb28181.cpp) and emits events through a REST API (src/api/server.cpp).
  • Benchmarking – docs/benchmarks/ hosts reproducible workloads and a CI workflow (.github/workflows/nightly-build-test-sophon.yml) that builds and tests on each target.

How It Is Wired

Entry Point – The main executable is built from src/main.cpp. The CMakeLists at the root invokes add_executable(cosmo-edge src/main.cpp …) and links against the third‑party libraries in 3rd/.

  1. main.cpp initializes the Engine singleton, which loads configuration from config.yaml (located in config/).
  2. Engine::loadScene() opens the scene JSON and creates Scene objects that own VideoSource and Detector instances.
  3. Each VideoSource (e.g., OnvifSource in src/video_onvif.cpp) opens an RTSP stream, then pushes frames into a FrameQueue.
  4. Detector subclasses (e.g., YoloDetector in src/detector/yolo.cpp) receive frames, run inference via the platform runtime (src/runtime/rknn.cpp or src/runtime/sophon.cpp), and emit DetectionEvent objects.
  5. EventDispatcher serialises events to JSON and writes them to a socket handled by ApiServer in src/api/server.cpp.
  6. The console UI (React/Vue in src/console/) polls the API endpoint /events and updates OSD overlays in real time.

The call graph is linear from main.cpp → Engine → VideoSource/Detector → EventDispatcher. No deep cycles exist; the only hub is the Engine which owns all subsystems. Modifying an event format requires touching src/api/server.cpp and src/engine/engine.h, while adding a new detector only needs a new subclass in src/detector/.

How To Use It

# Clone the repo
git clone https://github.com/moses-y/cosmo-edge
cd cosmo-edge

# Build the engine (C++17, CMake)
mkdir build && cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build

# Run the console (requires node/npm)
cd src/console
npm install
npm run dev

# Start the engine with a scene
./build/cosmo-edge --config config/default.yaml
  • Setup – The Dockerfile in 3rd/cryptopp-cmake-CRYPTOPP_8_9_0/.devcontainer/ shows the minimal runtime image; the CI workflow (.github/workflows/ci-build-and-test.yml) builds the same image.
  • Configuration – config/default.yaml contains the RTSP URLs, detector paths, and API port.
  • Running – The console UI is accessible at http://localhost:3000; the engine logs to logs/engine.log.

Missing: No explicit CLI flags are documented beyond --config; if you need environment variables, refer to the docs/en/guide/configuration.md.

Real-World Use

A security camera on a Rockchip RK3566 can run a YOLO‑v5 detector with 30 fps. Deploy the prebuilt RKNN runtime (rknn/) and point the engine to the device’s RTSP URL. The console will show live bounding boxes and push a POST /api/events to an external SIEM whenever an intruder crosses the zone.

Code Health & Issues

  • Security – The static scan identified 3 low‑severity secret paths: 3rd/openssl-3.5.3/apps/ca-key.pem, 3rd/openssl-3.5.3/apps/ca-req.pem, 3rd/openssl-3.5.3/apps/cert.pem. These files are test certificates and should be removed from production branches.
  • Testing – 5,602 test files exist, most under test/. CI is enabled via .github/workflows/ci-build-and-test.yml.
  • Documentation – 3,475 doc files exist; the README provides quick‑start guidance.
  • Licensing – Apache‑2.0; third‑party libs are permissively licensed.

The Bottom Line

CosmoEdge delivers a fully integrated C++ edge AI engine that abstracts platform differences and offers a web console for real‑time monitoring. The build process is straightforward with CMake, but the repo contains many third‑party dependencies that inflate the source tree. The main drawback is the presence of test certificates in the public repo; removing them will improve security hygiene. If you need a fast, consistent deployment pipeline across Sophon, Rockchip, and x86, this project is a solid base.