Projects/yolo_example: minimal YOLO detection with Darknet and OpenCV #18

Merged
ClaudeAI merged 1 commits from feature/yolo-example into master 49 minutes ago
Collaborator

Summary

Adds Projects/yolo_example, a small standalone example of YOLO object detection with the Darknet C++ API (hank-ai Darknet/YOLO V3+, darknet.hpp) and OpenCV 4.

What it does

  1. Loads a network from its three files with Darknet::load_neural_network(cfg, names, weights).
  2. Sets the filtering: set_detection_threshold() (0.25 by default, or the threshold from the command line) and set_non_maximal_suppression_threshold() (0.45).
  3. Runs YOLO with Darknet::predict(net, cv::Mat) on each image or frame, and prints each detection: class name, confidence, and the box in pixels.
  4. Draws the boxes with Darknet::annotate().
  5. Frees the network with Darknet::free_neural_network().

Input:

  • An image: the annotated copy is saved as <name>_output.jpg.
  • A video file or a camera index: the frames are shown in a window (q/Esc quits). Without a display, for example over ssh, the result is written to output.avi.

Files

  • yolo_example.cpp: about 170 lines.
  • Makefile: g++ -std=c++17 ... $(pkg-config --cflags --libs opencv4) -ldarknet.
  • README.md: build, model files (e.g. YOLOv4-tiny with COCO), usage, and how it works.
  • .gitignore: the binary and the output files.

Testing

Darknet is not available in the build container. The example was compiled (-Wall -Wextra, no warnings) against a stand-in darknet.hpp with the upstream declarations. It was also run with a stand-in network that returns one detection:

  • image mode: prints the detection and saves the annotated JPEG;
  • video mode without a display: writes output.avi;
  • errors: wrong arguments or a missing file end with a clear message.

Not yet run with real Darknet and real YOLO weights.

Generated with Claude Code

https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16

## Summary Adds `Projects/yolo_example`, a small standalone example of YOLO object detection with the Darknet C++ API (hank-ai Darknet/YOLO V3+, `darknet.hpp`) and OpenCV 4. ## What it does 1. **Loads a network** from its three files with `Darknet::load_neural_network(cfg, names, weights)`. 2. **Sets the filtering:** `set_detection_threshold()` (0.25 by default, or the threshold from the command line) and `set_non_maximal_suppression_threshold()` (0.45). 3. **Runs YOLO** with `Darknet::predict(net, cv::Mat)` on each image or frame, and prints each detection: class name, confidence, and the box in pixels. 4. **Draws the boxes** with `Darknet::annotate()`. 5. **Frees the network** with `Darknet::free_neural_network()`. Input: - **An image:** the annotated copy is saved as `<name>_output.jpg`. - **A video file or a camera index:** the frames are shown in a window (`q`/Esc quits). Without a display, for example over ssh, the result is written to `output.avi`. ## Files - `yolo_example.cpp`: about 170 lines. - `Makefile`: `g++ -std=c++17 ... $(pkg-config --cflags --libs opencv4) -ldarknet`. - `README.md`: build, model files (e.g. YOLOv4-tiny with COCO), usage, and how it works. - `.gitignore`: the binary and the output files. ## Testing Darknet is not available in the build container. The example was compiled (`-Wall -Wextra`, no warnings) against a stand-in `darknet.hpp` with the upstream declarations. It was also run with a stand-in network that returns one detection: - **image mode:** prints the detection and saves the annotated JPEG; - **video mode** without a display: writes `output.avi`; - **errors:** wrong arguments or a missing file end with a clear message. **Not yet run** with real Darknet and real YOLO weights. Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
ClaudeAI added 1 commit 49 minutes ago
45abb166de
Projects/yolo_example: minimal YOLO detection with Darknet and OpenCV
ClaudeAI merged commit 7aee0c0d70 into master 49 minutes ago
The pull request has been merged as 7aee0c0d70.
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This pull request currently doesn't have any dependencies.

Loading…
There is no content yet.