24
24
#include " hailo_postprocessing_stage.hpp"
25
25
26
26
using Size = libcamera::Size;
27
- using PostProcFuncPtr = void (*)(HailoROIPtr, YoloParams *);
28
- using PostProcFuncPtrNms = void (*)(HailoROIPtr);
27
+ using PostProcFuncPtrNms = void (*)(HailoROIPtr, YoloParams *);
29
28
using InitFuncPtr = YoloParams *(*)(std::string, std::string);
30
29
using FreeFuncPtr = void (*)(void *);
31
30
@@ -34,7 +33,6 @@ using Rectangle = libcamera::Rectangle;
34
33
namespace fs = std::filesystem;
35
34
36
35
#define NAME " hailo_yolo_inference"
37
- #define POSTPROC_LIB " libyolo_post.so"
38
36
#define POSTPROC_LIB_NMS " libyolo_hailortpp_post.so"
39
37
40
38
class YoloInference : public HailoPostProcessingStage
@@ -65,7 +63,6 @@ class YoloInference : public HailoPostProcessingStage
65
63
66
64
std::vector<LtObject> lt_objects_;
67
65
std::mutex lock_;
68
- PostProcessingLib postproc_;
69
66
PostProcessingLib postproc_nms_;
70
67
YoloParams *yolo_params_ = nullptr ;
71
68
@@ -82,16 +79,15 @@ class YoloInference : public HailoPostProcessingStage
82
79
};
83
80
84
81
YoloInference::YoloInference (RPiCamApp *app)
85
- : HailoPostProcessingStage(app), postproc_(PostProcLibDir(POSTPROC_LIB)),
86
- postproc_nms_(PostProcLibDir(POSTPROC_LIB_NMS))
82
+ : HailoPostProcessingStage(app), postproc_nms_(PostProcLibDir(POSTPROC_LIB_NMS))
87
83
{
88
84
}
89
85
90
86
YoloInference::~YoloInference ()
91
87
{
92
88
if (yolo_params_)
93
89
{
94
- FreeFuncPtr free_func = reinterpret_cast <FreeFuncPtr>(postproc_ .GetSymbol (" free_resources" ));
90
+ FreeFuncPtr free_func = reinterpret_cast <FreeFuncPtr>(postproc_nms_ .GetSymbol (" free_resources" ));
95
91
if (free_func)
96
92
free_func (yolo_params_);
97
93
}
@@ -118,14 +114,14 @@ void YoloInference::Read(boost::property_tree::ptree const ¶ms)
118
114
else
119
115
temporal_filtering_ = false ;
120
116
121
- InitFuncPtr init = reinterpret_cast <InitFuncPtr>(postproc_ .GetSymbol (" init" ));
122
- const std::string config_file = params.get <std::string>(" hailopp_config_file" , " " );
123
- if (init && !config_file.empty ())
117
+ InitFuncPtr init = reinterpret_cast <InitFuncPtr>(postproc_nms_ .GetSymbol (" init" ));
118
+ const std::string config_file = params.get <std::string>(" hailopp_config_file" , {} );
119
+ if (!config_file.empty ())
124
120
{
125
121
if (!fs::exists (config_file))
126
122
throw std::runtime_error (std::string (" hailo postprocess config file not found: " ) + config_file);
127
- yolo_params_ = init (config_file, " " );
128
123
}
124
+ yolo_params_ = init (config_file, " " );
129
125
130
126
HailoPostProcessingStage::Read (params);
131
127
}
@@ -238,12 +234,8 @@ std::vector<Detection> YoloInference::runInference(const uint8_t *frame, const s
238
234
{
239
235
hailort::AsyncInferJob job;
240
236
std::vector<OutTensor> output_tensors;
241
- bool nms_on_hailo = false ;
242
237
hailo_status status;
243
238
244
- if (infer_model_->outputs ().size () == 1 && infer_model_->outputs ()[0 ].is_nms ())
245
- nms_on_hailo = true ;
246
-
247
239
status = HailoPostProcessingStage::DispatchJob (frame, job, output_tensors);
248
240
if (status != HAILO_SUCCESS)
249
241
return {};
@@ -260,24 +252,9 @@ std::vector<Detection> YoloInference::runInference(const uint8_t *frame, const s
260
252
}
261
253
262
254
HailoROIPtr roi = MakeROI (output_tensors);
255
+ PostProcFuncPtrNms filter = reinterpret_cast <PostProcFuncPtrNms>(postproc_nms_.GetSymbol (" filter" ));
263
256
264
- if (nms_on_hailo)
265
- {
266
- PostProcFuncPtrNms filter = reinterpret_cast <PostProcFuncPtrNms>(postproc_nms_.GetSymbol (" filter" ));
267
- if (!filter)
268
- return {};
269
-
270
- filter (roi);
271
- }
272
- else
273
- {
274
- PostProcFuncPtr filter = reinterpret_cast <PostProcFuncPtr>(postproc_.GetSymbol (" filter" ));
275
- if (!filter)
276
- return {};
277
-
278
- filter (roi, yolo_params_);
279
- }
280
-
257
+ filter (roi, yolo_params_);
281
258
std::vector<HailoDetectionPtr> detections = hailo_common::get_hailo_detections (roi);
282
259
283
260
LOG (2 , " ------" );
0 commit comments