|
5 | 5 | #include <fstream> |
6 | 6 | #include <random> |
7 | 7 |
|
8 | | -void Detector(YOLO_V8*& p) { |
| 8 | +void Detector(std::unique_ptr<YOLO_V8>& p) { |
9 | 9 | std::filesystem::path current_path = std::filesystem::current_path(); |
10 | 10 | std::filesystem::path imgs_path = current_path / "images"; |
11 | 11 | for (auto& i : std::filesystem::directory_iterator(imgs_path)) |
@@ -58,7 +58,7 @@ void Detector(YOLO_V8*& p) { |
58 | 58 | } |
59 | 59 |
|
60 | 60 |
|
61 | | -void Classifier(YOLO_V8*& p) |
| 61 | +void Classifier(std::unique_ptr<YOLO_V8>& p) |
62 | 62 | { |
63 | 63 | std::filesystem::path current_path = std::filesystem::current_path(); |
64 | 64 | std::filesystem::path imgs_path = current_path;// / "images" |
@@ -97,7 +97,7 @@ void Classifier(YOLO_V8*& p) |
97 | 97 |
|
98 | 98 |
|
99 | 99 |
|
100 | | -int ReadCocoYaml(YOLO_V8*& p) { |
| 100 | +int ReadCocoYaml(std::unique_ptr<YOLO_V8>& p) { |
101 | 101 | // Open the YAML file |
102 | 102 | std::ifstream file("coco.yaml"); |
103 | 103 | if (!file.is_open()) |
@@ -148,7 +148,9 @@ int ReadCocoYaml(YOLO_V8*& p) { |
148 | 148 |
|
149 | 149 | void DetectTest() |
150 | 150 | { |
151 | | - YOLO_V8* yoloDetector = new YOLO_V8; |
| 151 | + //YOLO_V8* yoloDetector = new YOLO_V8; |
| 152 | + std::unique_ptr<YOLO_V8> yoloDetector = std::make_unique<YOLO_V8>(); |
| 153 | + |
152 | 154 | ReadCocoYaml(yoloDetector); |
153 | 155 | DL_INIT_PARAM params; |
154 | 156 | params.rectConfidenceThreshold = 0.1; |
@@ -177,7 +179,7 @@ void DetectTest() |
177 | 179 |
|
178 | 180 | void ClsTest() |
179 | 181 | { |
180 | | - YOLO_V8* yoloDetector = new YOLO_V8; |
| 182 | + std::unique_ptr<YOLO_V8> yoloDetector = std::make_unique<YOLO_V8>(); |
181 | 183 | std::string model_path = "cls.onnx"; |
182 | 184 | ReadCocoYaml(yoloDetector); |
183 | 185 | DL_INIT_PARAM params{ model_path, YOLO_CLS, {224, 224} }; |
|
0 commit comments