# CosmoEdge

> A C++ edge AI engine that turns video models into deployable analytics apps on Sophon, Rockchip and x86

- Category: Multimodal Generation / Vision & Understanding
- Language: C++
- Licence: Apache-2.0
- Repository: https://github.com/cosmo-wander-ai/cosmo-edge
- Website: https://www.cosmowander.ai/
- Canonical page: https://ai-tldr.dev/tools/cosmo-edge/

## In short

CosmoEdge is an open-source edge AI engine for video. It sits in the Vision & Understanding category of the Multimodal Generation tools and is open-source, written in C++ and licensed Apache-2.0. To get started: clone and start on x86.

## Overview

CosmoEdge is an open-source edge AI engine for video. Its core is a C++17 runtime that handles multi-channel media, inference scheduling, on-screen display (OSD), tasks and events, and on top of it sits a web console where you compose the application: which model runs on which camera, which rules turn detections into alarms, and where those alarms go. The project describes its aim as going beyond model serving to a full application layer for model import, visual orchestration, alarms and event delivery.

One engine architecture targets several hardware families, but each build selects a single inference backend and uses model artifacts generated for that platform: Sophon BM1688 and CV186X through BMRT with `.nn` models, Rockchip RK3576 and RV1126B through RKNN with `.rknn` models (plus RKLLM on RK3576), and x86 Linux or Windows through ONNX Runtime with `.onnx` models. An Apple Silicon macOS path runs as a Docker preview under `linux/amd64` emulation for a single local-video workflow. Beyond conventional detection, classification and tracking, it supports prompt-driven vision: VLM state judgment and GroundingDINO open-vocabulary detection, including optional VLM review before a detection alarm is reported.

The v1.1 release ships a public benchmark pack covering single and concurrent mixed workloads, a controlled 72-hour dual-CV profile and validated VLM performance on BM1688, CV186X and RK3576, with the methodology and source commits recorded. The core engine and console are Apache-2.0; certified hardware, commercial preset models and the Model Guard encryption for Sophon Protected packages sit outside that boundary, and the project states that Open and Protected packages expose the same application features.

## What it does

- Native C++17 runtime for multi-channel video decode, inference scheduling, tracking, zones, counters, OSD and alarm snapshots
- Browser-based visual orchestration: chain input processing, model inference and rule nodes into a business flow, with detection areas and parameter validation
- Prompt-driven vision with VLM state judgment and GroundingDINO open-vocabulary detection alongside conventional CV pipelines
- Platform backends for Sophon (BMRT), Rockchip (RKNN with MPP/RGA media paths) and x86 (ONNX Runtime), each with target-specific model artifacts
- Event delivery and management through REST, WebSocket, MQTT and HTTP webhooks, plus model management and event history
- Model porting path for importing your own trained models, and an agent-assisted development guide for handing porting or integration tasks to a coding agent

## Getting started

No edge hardware is needed to try it: the x86 mode runs the same UI and workflow in Docker, with lower throughput than an NPU deployment. Device builds are packaged per chip.

1. Clone and start on x86

   On Linux, bring the stack up with Docker Compose; Windows uses its own compose file. Docker Compose V1 users can replace `docker compose` with `docker-compose`.

```bash
git clone https://github.com/cosmo-wander-ai/cosmo-edge.git
cd cosmo-edge

# Linux
sudo docker compose -f docker-compose.x86.yml up -d --build
# Windows: docker compose -f docker-compose.x86.windows.yml up -d --build
```

2. Or use the macOS Docker Preview

   Apple Silicon Macs run a single local-video workflow under linux/amd64 emulation.

```bash
./scripts/macos-docker-preview.sh doctor
./scripts/macos-docker-preview.sh up
./scripts/macos-docker-preview.sh status
```

3. Open the console and create a task

   Browse to http://localhost:8080 (http://127.0.0.1:8080 on the Mac preview), then follow the Scenario Configuration tutorial to create your first AI detection task.

4. Build a package for an edge device

   Sophon builds export each chip under `build_output/public-runtime/<chip>/` with `TARGET_CHIP` and `SHA256SUMS`; Rockchip builds export under `build_output/<chip>/`. RV1126B needs a prepared target model overlay.

```bash
# Sophon BM1688 / CV186X
./scripts/docker-compose.sh -f docker-compose.sophon.yml run --rm cosmo-sophon-package --chip bm1688
./scripts/docker-compose.sh -f docker-compose.sophon.yml run --rm cosmo-sophon-package --chip cv186x

# Rockchip RK3576
./scripts/docker-compose.sh -f docker-compose.rockchip.yml pull cosmo-rockchip-package
COSMO_TARGET_CHIP=rk3576 ./scripts/docker-compose.sh \
  -f docker-compose.rockchip.yml run --rm cosmo-rockchip-package
ls -lh build_output/rk3576/
```

## When to use it

- Run multi-camera safety analytics such as no-safety-helmet or region-intrusion alarms on a Sophon or Rockchip box at the edge
- Describe what to look for in a prompt with GroundingDINO or a VLM instead of training a new detector for every object
- Push structured alarm events from cameras into existing systems over MQTT, WebSocket, REST or HTTP webhooks
- Prototype a video analytics pipeline on an x86 laptop in Docker before porting the models to an NPU target
