Skip to content

Add C++ ONNX Demo - #76

Draft
sctrueew wants to merge 4 commits into
roboflow:developfrom
sctrueew:cpp-rf-detr-demo
Draft

Add C++ ONNX Demo#76
sctrueew wants to merge 4 commits into
roboflow:developfrom
sctrueew:cpp-rf-detr-demo

Conversation

@sctrueew

@sctrueew sctrueew commented Mar 28, 2025

Copy link
Copy Markdown

This PR introduces a C++ demo for the RF-DETR model, allowing users to perform real-time object detection using an ONNX model. The demo supports various input sources, including images, videos, and live camera streams, with optional CUDA acceleration.

Key Features:
✅ Loads an RF-DETR model in ONNX format
✅ Supports image, video, and live camera inference
✅ Enables CPU and CUDA (GPU) execution
✅ Configurable confidence threshold for detections
✅ Outputs annotated images/videos with detected objects
✅ Uses COCO class labels for object recognition

Run Examples:
🔹 Image Inference:
Detect objects in a static image and save the output:

./main--model path/to/model.onnx --source_type image \
  --input path/to/image.jpg --output path/to/output.jpg \
  --conf 0.6 --labels path/to/coco.names

🔹 Video Inference:
Process a video file and save the annotated output:

./main --model path/to/model.onnx --source_type video \
  --input path/to/video.mp4 --output path/to/output.mp4 \
  --conf 0.5 --use_cuda

🔹 Live Camera Inference (Default ID 0):
Run inference on the default webcam (ID 0) with GPU acceleration:

./main --model path/to/model.onnx --source_type camera \
  --input 0 --conf 0.55 --use_cuda

🔹 Live Camera Inference (Specific Camera ID 1):
Run inference on a specific camera (ID 1):

./main --model path/to/model.onnx --source_type camera \
  --input 1 --conf 0.55

🔹 Get Help & Available Options:

./main --help
Dependencies:

  • OpenCV (for image and video processing)
  • ONNX Runtime (for model inference)
  • CUDA (optional, for GPU acceleration)

@CLAassistant

CLAassistant commented Mar 28, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@probicheaux

Copy link
Copy Markdown
Collaborator

Hey @sctrueew, really cool work! Would love to merge. Can you sign the CLA?

@SkalskiP
SkalskiP changed the base branch from main to develop April 3, 2025 08:53
@sctrueew

sctrueew commented Apr 3, 2025

Copy link
Copy Markdown
Author

Hey @sctrueew, really cool work! Would love to merge. Can you sign the CLA?

Yes, I have agreed the CLA

@SkalskiP

SkalskiP commented Apr 3, 2025

Copy link
Copy Markdown
Collaborator

Hi @sctrueew, thanks for accepting the CLA! Would it be possible for you to add a README in inference/cpp that explains how to set up the project, install the necessary dependencies, and run the model in C++? This would make it much easier for new users to get started with your demo. Thanks again for your contribution!

@sctrueew

sctrueew commented Apr 3, 2025

Copy link
Copy Markdown
Author

Hi @sctrueew, thanks for accepting the CLA! Would it be possible for you to add a README in inference/cpp that explains how to set up the project, install the necessary dependencies, and run the model in C++? This would make it much easier for new users to get started with your demo. Thanks again for your contribution!

Hi @SkalskiP, I have added a README file to the project. Please let me know if you need any further changes or additional information.

@mohamedsamirx mohamedsamirx mentioned this pull request Apr 4, 2025
1 task
…DETR_ONNX.cpp for better structure and maintainability
@isaacrob

Copy link
Copy Markdown
Contributor

what's the utility of having a large scale devoted c++ demo in this otherwise python-only repo?

@Borda

Borda commented May 21, 2026

Copy link
Copy Markdown
Member

@sctrueew, thank you for your suggestion and for sending this PR I believe this repo is more about research, training, and experimentation, and your C++ demo, however, it is cool and I like it more on deployment, from which we try to solve with our other package inference, which is also optimized for this 🦝

@Borda
Borda marked this pull request as draft May 21, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants