Conversation
…ssion in case of multiple inputs (to avoid necessary initializations).
… ed_sensor_integration
4ecaf3c to
ad9cf19
Compare
c4770a4 to
90afade
Compare
b87a311 to
6226976
Compare
There was a problem hiding this comment.
Pull request overview
This PR transforms a standalone YOLOv8 ONNX inference C++ implementation into a ROS (Robot Operating System) package called yolo_onnx_ros. The changes refactor the codebase to follow ROS conventions, improve modularity, add comprehensive testing, and update build configuration for catkin integration.
Key Changes:
- Restructured code into ROS package with proper header organization and catkin build system
- Refactored member variables to use trailing underscore naming convention
- Added unit tests using Google Test framework for YOLO inference functionality
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| CMakeLists.txt | Complete rebuild system migration from standalone CMake to catkin with testing support and automated model downloads |
| package.xml | New ROS package manifest defining dependencies and metadata |
| src/yolo_inference.cpp | Core inference logic with member variable renaming, input validation, and dimension order fixes |
| include/yolo_onnx_ros/yolo_inference.hpp | Header refactored with trailing underscore convention and CUDA macro updates |
| src/detection.cpp | New detection utilities extracted from main, including YAML parsing and initialization functions |
| include/yolo_onnx_ros/detection.hpp | New header exposing detection API functions |
| src/main.cpp | Simplified main function using new detection API |
| test/yolo_test.cpp | New comprehensive unit tests for YOLO inference pipeline |
| include/yolo_onnx_ros/config.hpp.in | CMake-generated configuration template for CUDA feature detection |
| data/open-images-v7.yaml | Reference dataset configuration with 601 class definitions |
| README.md | Updated documentation for ROS integration and CUDA version requirements |
| .vscode/* | VSCode configuration files for development environment |
| .github/workflows/main.yml | GitHub Actions CI workflow using TUe robotics infrastructure |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| cv::RNG rng(cv::getTickCount()); | ||
| cv::Scalar color(rng.uniform(0, 256), rng.uniform(0, 256), rng.uniform(0, 256)); | ||
|
|
||
| cv::rectangle(img, re.box, color, 3); |
There was a problem hiding this comment.
The function draws on a const-qualified cv::Mat. The img parameter is passed as const cv::Mat& (line 8), but cv::rectangle modifies the image. This will cause a compilation error. Change the parameter to cv::Mat& to allow modification.
| cv::randu(testImage_realistic, cv::Scalar(0, 0, 0), cv::Scalar(255, 255, 255)); | ||
|
|
||
| // Setup common parameters | ||
| std::tie(yolo, params) = Initialize("./yolo11m.onnx"); |
There was a problem hiding this comment.
The Initialize function expects a std::filesystem::path but is called with a C-string literal. While this may work due to implicit conversion, it's more explicit to construct the path: Initialize(std::filesystem::path(\"./yolo11m.onnx\")).
src/yolo_inference.cpp
Outdated
|
|
||
| template<typename N> | ||
| char* YOLO_V8::TensorProcess(clock_t& starttime_1, const cv::Mat& iImg, N& blob, std::vector<int64_t>& inputNodeDims, | ||
| char* YOLO_V8::TensorProcess(clock_t& starttime_1, const cv::Mat&, N& blob, std::vector<int64_t>& inputNodeDims, |
There was a problem hiding this comment.
The unnamed parameter (const cv::Mat&) is confusing. If the parameter is intentionally unused, name it with a comment explaining why, or use [[maybe_unused]] attribute: [[maybe_unused]] const cv::Mat& iImg.
| char* YOLO_V8::TensorProcess(clock_t& starttime_1, const cv::Mat&, N& blob, std::vector<int64_t>& inputNodeDims, | |
| char* YOLO_V8::TensorProcess(clock_t& starttime_1, [[maybe_unused]] const cv::Mat& iImg, N& blob, std::vector<int64_t>& inputNodeDims, |
src/yolo_inference.cpp
Outdated
| cv::dnn::NMSBoxes(boxes, confidences, rectConfidenceThreshold, iouThreshold, nmsResult); | ||
| for (int i = 0; i < nmsResult.size(); ++i) | ||
| cv::dnn::NMSBoxes(boxes, confidences, rectConfidenceThreshold_, iouThreshold_, nmsResult); | ||
| for (uint i = 0; i < nmsResult.size(); ++i) |
There was a problem hiding this comment.
Using uint instead of size_t for vector iteration is non-standard. Replace with size_t or use a range-based for loop to avoid type mismatch warnings and ensure portability.
| for (uint i = 0; i < nmsResult.size(); ++i) | |
| for (size_t i = 0; i < nmsResult.size(); ++i) |
src/yolo_inference.cpp
Outdated
|
|
||
| DL_RESULT result; | ||
| for (int i = 0; i < this->classes.size(); i++) | ||
| for (uint i = 0; i < this->classes.size(); i++) |
There was a problem hiding this comment.
Using uint instead of size_t for vector iteration is non-standard. Replace with size_t or use a range-based for loop to avoid type mismatch warnings and ensure portability.
| for (uint i = 0; i < this->classes.size(); i++) | |
| for (size_t i = 0; i < this->classes.size(); i++) |
include/yolo_onnx_ros/detection.hpp
Outdated
| #include "yolo_onnx_ros/yolo_inference.hpp" | ||
|
|
||
| #include <filesystem> | ||
|
|
There was a problem hiding this comment.
The commented-out #define LOGGING suggests this is used for conditional compilation, but there's no documentation explaining when/why a developer should enable it. Add a comment explaining its purpose and usage.
| // Uncomment the following line to enable additional logging output for debugging purposes. | |
| // When LOGGING is defined, diagnostic messages will be printed to help trace execution and troubleshoot issues. | |
| // Enable this during development or debugging; leave it commented out in production for better performance and less verbosity. |
src/yolo_inference.cpp
Outdated
| { | ||
| int signalResultNum = outputNodeDims[1];//84 | ||
| int strideNum = outputNodeDims[2];//8400 | ||
| int signalResultNum = outputNodeDims[1]; // Should be 605 for OIV7 (4 bbox + 601 classes) |
There was a problem hiding this comment.
The comment mentions OIV7 with 605 (4 bbox + 601 classes), but this appears to be dataset-specific. Add clarification that this value varies by dataset (e.g., 84 for COCO: 4 bbox + 80 classes).
| int signalResultNum = outputNodeDims[1]; // Should be 605 for OIV7 (4 bbox + 601 classes) | |
| int signalResultNum = outputNodeDims[1]; // Dataset-specific: e.g., 605 for OIV7 (4 bbox + 601 classes), 84 for COCO (4 bbox + 80 classes) |
…(flexible onnx dims) on muptiple pretrained datasets (flexible yaml reading files)
f669f5e to
cf92346
Compare
2e3dba4 to
e6e5bc5
Compare
No description provided.