Skip to content

Commit a6243d9

Browse files
committed
Merge branch 'feat/data-aggregation' of https://github.com/tritonuas/obcpp into feat/data-aggregation
2 parents 934e5ad + de7dc2a commit a6243d9

File tree

5 files changed

+29
-10
lines changed

5 files changed

+29
-10
lines changed

include/cv/pipeline.hpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <cmath>
55
#include <memory>
6+
#include <optional>
67
#include <string>
78
#include <utility>
89
#include <vector>
@@ -29,14 +30,21 @@ struct PipelineResults {
2930
};
3031

3132
struct PipelineParams {
32-
// Added outputPath parameter with default empty string
33-
explicit PipelineParams(std::string yoloModelPath, std::string outputPath = "",
33+
// yoloModelPath is optional; when absent, no CV models will be loaded.
34+
explicit PipelineParams(std::optional<std::string> yoloModelPath = std::nullopt,
35+
std::string outputPath = "",
3436
bool do_preprocess = true)
3537
: yoloModelPath{std::move(yoloModelPath)},
3638
outputPath(std::move(outputPath)),
3739
do_preprocess(do_preprocess) {}
3840

39-
std::string yoloModelPath;
41+
explicit PipelineParams(const std::string& yoloModelPath,
42+
std::string outputPath = "",
43+
bool do_preprocess = true)
44+
: PipelineParams(std::optional<std::string>(yoloModelPath), std::move(outputPath),
45+
do_preprocess) {}
46+
47+
std::optional<std::string> yoloModelPath;
4048
bool do_preprocess;
4149
std::string outputPath;
4250
};

include/udp_squared

protos

Submodule protos updated 1 file

src/cv/pipeline.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,18 @@
77

88
// Pipeline constructor: initialize YOLO detector and the preprocess flag.
99
Pipeline::Pipeline(const PipelineParams& p)
10-
: yoloDetector(std::make_unique<YOLO>(p.yoloModelPath, 0.05f, 640, 640)),
11-
outputPath(p.outputPath),
12-
do_preprocess(p.do_preprocess) {}
10+
: outputPath(p.outputPath),
11+
do_preprocess(p.do_preprocess) {
12+
if (p.yoloModelPath.has_value() && !p.yoloModelPath->empty()) {
13+
yoloDetector = std::make_unique<YOLO>(*p.yoloModelPath, 0.05f, 640, 640);
14+
LOG_F(INFO, "YOLO model loaded from path: %s", p.yoloModelPath->c_str());
15+
} else {
16+
yoloDetector.reset();
17+
LOG_F(WARNING, "No CV models are loaded (no YOLO model path provided).");
18+
LOG_F(WARNING, "CVAGGREGATOR WILL NOT BE WORKING AS INTENDED. USE AT YOUR OWN RISK.");
19+
LOG_F(WARNING, "Provide a YOLO model path to enable detections.");
20+
}
21+
}
1322

1423
PipelineResults Pipeline::run(const ImageData& imageData) {
1524
LOG_F(INFO, "Running pipeline on an image");
@@ -88,7 +97,9 @@ PipelineResults Pipeline::run(const ImageData& imageData) {
8897

8998
// 3) DRAW DETECTIONS ON THE IMAGE
9099
// (this modifies processedImage in-place)
91-
this->yoloDetector->drawAndPrintDetections(processedImage, yoloResults);
100+
if (this->yoloDetector) {
101+
this->yoloDetector->drawAndPrintDetections(processedImage, yoloResults);
102+
}
92103

93104
// Save the annotated image if an output path is specified
94105
if (!outputPath.empty()) {

tests/unit/modify_runs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "cv/aggregator.hpp"
33
TEST(ModifyRuns, OverWriteData)
44
{
5-
PipelineParams params("/workspaces/obcpp/models/yolo11x.onnx",
5+
PipelineParams params(std::nullopt,
66
"",
77
false);
88
Pipeline pipeline(params);

0 commit comments

Comments
 (0)