Skip to content

Commit da49f68

Browse files
committed
fix openvino
1 parent f4ed2dd commit da49f68

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

yolox_ros_cpp/yolox_cpp/include/yolox_cpp/yolox_openvino.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
namespace yolox_cpp{
1616
class YoloXOpenVINO: public AbcYoloX{
1717
public:
18-
YoloXOpenVINO(file_name_t path_to_model, std::string device_name,
19-
float nms_th=0.45, float conf_th=0.3, std::string model_version="0.1.1rc0",
18+
YoloXOpenVINO(const file_name_t &path_to_model, std::string device_name,
19+
float nms_th=0.45, float conf_th=0.3, const std::string &model_version="0.1.1rc0",
2020
int num_classes=80, bool p6=false);
2121
std::vector<Object> inference(const cv::Mat& frame) override;
2222

@@ -28,4 +28,4 @@ namespace yolox_cpp{
2828
};
2929
}
3030

31-
#endif
31+
#endif

yolox_ros_cpp/yolox_cpp/src/yolox_openvino.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "yolox_cpp/yolox_openvino.hpp"
22

33
namespace yolox_cpp{
4-
YoloXOpenVINO::YoloXOpenVINO(file_name_t path_to_model, std::string device_name,
5-
float nms_th, float conf_th, std::string model_version,
4+
YoloXOpenVINO::YoloXOpenVINO(const file_name_t &path_to_model, std::string device_name,
5+
float nms_th, float conf_th, const std::string &model_version,
66
int num_classes, bool p6)
77
:AbcYoloX(nms_th, conf_th, model_version, num_classes, p6),
88
device_name_(device_name)
@@ -69,14 +69,16 @@ namespace yolox_cpp{
6969
ov::Tensor{ov::element::f32, this->input_shape_, reinterpret_cast<float *>(this->blob_.data())});
7070
infer_request_.infer();
7171

72-
7372
const auto &output_tensor = this->infer_request_.get_output_tensor();
7473
const float* net_pred = reinterpret_cast<float *>(output_tensor.data());
7574

76-
float scale = std::min(input_w_ / (frame.cols*1.0), input_h_ / (frame.rows*1.0));
75+
const float scale = std::min(
76+
static_cast<float>(this->input_w_) / static_cast<float>(frame.cols),
77+
static_cast<float>(this->input_h_) / static_cast<float>(frame.rows)
78+
);
79+
7780
std::vector<Object> objects;
7881
decode_outputs(net_pred, this->grid_strides_, objects, this->bbox_conf_thresh_, scale, frame.cols, frame.rows);
7982
return objects;
8083
}
81-
82-
}
84+
}

0 commit comments

Comments
 (0)