Skip to content

Commit f4ed2dd

Browse files
committed
fix onnxruntime
1 parent 08cde41 commit f4ed2dd

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

yolox_ros_cpp/yolox_cpp/include/yolox_cpp/yolox_onnxruntime.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@
88
#include <iostream>
99
#include <opencv2/opencv.hpp>
1010

11-
#include "onnxruntime/core/session/onnxruntime_cxx_api.h"
11+
#include <onnxruntime/onnxruntime_cxx_api.h>
1212

1313
#include "core.hpp"
1414
#include "coco_names.hpp"
1515

1616
namespace yolox_cpp{
1717
class YoloXONNXRuntime: public AbcYoloX{
1818
public:
19-
YoloXONNXRuntime(file_name_t path_to_model,
19+
YoloXONNXRuntime(const file_name_t &path_to_model,
2020
int intra_op_num_threads, int inter_op_num_threads=1,
2121
bool use_cuda=true, int device_id=0, bool use_parallel=false,
22-
float nms_th=0.45, float conf_th=0.3, std::string model_version="0.1.1rc0",
22+
float nms_th=0.45, float conf_th=0.3, const std::string &model_version="0.1.1rc0",
2323
int num_classes=80, bool p6=false);
2424
std::vector<Object> inference(const cv::Mat& frame) override;
2525

2626
private:
2727
int intra_op_num_threads_ = 1;
2828
int inter_op_num_threads_ = 1;
29-
int device_id_ = 0;
3029
bool use_cuda_ = true;
30+
int device_id_ = 0;
3131
bool use_parallel_ = false;
3232

3333
Ort::Session session_{nullptr};

yolox_ros_cpp/yolox_cpp/src/yolox_onnxruntime.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace yolox_cpp{
44

5-
YoloXONNXRuntime::YoloXONNXRuntime(file_name_t path_to_model,
5+
YoloXONNXRuntime::YoloXONNXRuntime(const file_name_t &path_to_model,
66
int intra_op_num_threads, int inter_op_num_threads,
77
bool use_cuda, int device_id, bool use_parallel,
8-
float nms_th, float conf_th, std::string model_version,
8+
float nms_th, float conf_th, const std::string &model_version,
99
int num_classes, bool p6)
1010
:AbcYoloX(nms_th, conf_th, model_version, num_classes, p6),
1111
intra_op_num_threads_(intra_op_num_threads), inter_op_num_threads_(inter_op_num_threads),
@@ -138,7 +138,10 @@ namespace yolox_cpp{
138138
float* net_pred = (float *)this->output_buffer_[0].get();
139139

140140
// post process
141-
float scale = std::min(input_w_ / (frame.cols*1.0), input_h_ / (frame.rows*1.0));
141+
const float scale = std::min(
142+
static_cast<float>(this->input_w_) / static_cast<float>(frame.cols),
143+
static_cast<float>(this->input_h_) / static_cast<float>(frame.rows)
144+
);
142145
std::vector<Object> objects;
143146
decode_outputs(net_pred, this->grid_strides_, objects, this->bbox_conf_thresh_, scale, frame.cols, frame.rows);
144147
return objects;

0 commit comments

Comments
 (0)