Skip to content

Commit 90afade

Browse files
Added optional argument for images (you need to provide it only for the executable)
1 parent ad9cf19 commit 90afade

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

.vscode/launch.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
"name": "Debug Yolo Model",
66
"type": "cppdbg",
77
"request": "launch",
8-
"program": "${workspaceFolder}/build/devel/lib/yolo_onnx_ros/test_yolo_onnx_ros", // Path to the executable
9-
"args": [], // Add any command-line arguments for your program here
8+
"program": "/home/amigo/ros/noetic/system/devel/lib/yolo_onnx_ros/test_yolo_onnx_ros", // Path to the executable
9+
"args": [
10+
"/home/amigo/ros/noetic/repos/github.com/tue-robotics/yolo_onnx_ros/data/yolo11m.onnx",
11+
"/home/amigo/Documents/repos/hero_sam.bak/pipeline/build/images"
12+
], // Add any command-line arguments for your program here
1013
"stopAtEntry": false,
1114
"cwd": "${workspaceFolder}/build", // Set the working directory
1215
"environment": [],
@@ -19,13 +22,13 @@
1922
"ignoreFailures": true
2023
}
2124
],
22-
"preLaunchTask": "build-yolo-project" // Ensure the project is built before debugging
25+
//"preLaunchTask": "build-yolo-project" // Ensure the project is built before debugging
2326
},
2427
{
2528
"name": "Debug Yolo Test",
2629
"type": "cppdbg",
2730
"request": "launch",
28-
"program": "${workspaceFolder}/build/Yolov8OnnxRuntimeCPPInference_test", // Path to the executable
31+
"program": "/home/amigo/ros/noetic/system/devel/lib/yolo_onnx_ros/yolo_test", // Path to the executable
2932
"args": [], // Add any command-line arguments for your program here
3033
"stopAtEntry": false,
3134
"cwd": "${workspaceFolder}/build", // Set the working directory
@@ -39,7 +42,7 @@
3942
"ignoreFailures": true
4043
}
4144
],
42-
"preLaunchTask": "build-yolo-project" // Ensure the project is built before debugging
45+
//"preLaunchTask": "build-yolo-project" // Ensure the project is built before debugging
4346
}
4447
]
4548
}

include/yolo_onnx_ros/detection.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <filesystem>
44

5+
// #define LOGGING
56
std::tuple<std::unique_ptr<YOLO_V8>, DL_INIT_PARAM> Initialize(const std::filesystem::path& model_filename);
67

78
std::vector<DL_RESULT> Detector(std::unique_ptr<YOLO_V8>& p, const cv::Mat& img);

src/detection.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <iomanip>
66
#include <iostream>
77

8-
// #define LOGGING
98
std::vector<DL_RESULT> Detector(std::unique_ptr<YOLO_V8>& p, const cv::Mat& img) {
109

1110
std::vector<DL_RESULT> res;

src/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ int main(int argc, char *argv[])
2020

2121
std::tie(yoloDetector, params) = Initialize(model_name);
2222

23-
std::filesystem::path current_path = std::filesystem::current_path();
24-
std::filesystem::path imgs_path = current_path / "images";
23+
std::filesystem::path imgs_path = argv[2];
2524
for (auto& i : std::filesystem::directory_iterator(imgs_path))
2625
{
2726
if (i.path().extension() == ".jpg" || i.path().extension() == ".png" || i.path().extension() == ".jpeg")
@@ -30,12 +29,14 @@ int main(int argc, char *argv[])
3029
cv::Mat img = cv::imread(img_path);
3130
std::vector<DL_RESULT> results;
3231
results = Detector(yoloDetector, img);
32+
#ifdef LOGGING
3333
for (const auto& result : results)
3434
{
3535
std::cout << "Image path: " << img_path << "\n"
3636
<< "class id: " << result.classId << "\n"
3737
<< "confidence: " << result.confidence << "\n";
3838
}
39+
#endif
3940
}
4041
}
4142

0 commit comments

Comments
 (0)