Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed Ubuntu+gcc build error for std::xxxf (#81) #82

Merged
merged 2 commits into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lite/mnn/cv/mnn_nanodet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void MNNNanoDet::resize_unscale(const cv::Mat &mat, cv::Mat &mat_rs,
// scale ratio (new / old) new_shape(h,w)
float w_r = (float) target_width / (float) img_width;
float h_r = (float) target_height / (float) img_height;
float r = std::fmin(w_r, h_r);
float r = std::min(w_r, h_r);
// compute padding
int new_unpad_w = static_cast<int>((float) img_width * r); // floor
int new_unpad_h = static_cast<int>((float) img_height * r); // floor
Expand Down Expand Up @@ -213,10 +213,10 @@ void MNNNanoDet::generate_bboxes_single_stride(const NanoScaleParams &scale_para
float y1 = ((cy - t) * s - (float) dh) / ratio; // cy - t y1
float x2 = ((cx + r) * s - (float) dw) / ratio; // cx + r x2
float y2 = ((cy + b) * s - (float) dh) / ratio; // cy + b y2
box.x1 = std::fmax(0.f, x1);
box.y1 = std::fmax(0.f, y1);
box.x2 = std::fmin(img_width, x2);
box.y2 = std::fmin(img_height, y2);
box.x1 = std::max(0.f, x1);
box.y1 = std::max(0.f, y1);
box.x2 = std::min(img_width, x2);
box.y2 = std::min(img_height, y2);
box.score = cls_conf;
box.label = label;
box.label_text = class_names[label];
Expand Down
10 changes: 5 additions & 5 deletions lite/mnn/cv/mnn_nanodet_efficientnet_lite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void MNNNanoDetEfficientNetLite::resize_unscale(const cv::Mat &mat, cv::Mat &mat
// scale ratio (new / old) new_shape(h,w)
float w_r = (float) target_width / (float) img_width;
float h_r = (float) target_height / (float) img_height;
float r = std::fmin(w_r, h_r);
float r = std::min(w_r, h_r);
// compute padding
int new_unpad_w = static_cast<int>((float) img_width * r); // floor
int new_unpad_h = static_cast<int>((float) img_height * r); // floor
Expand Down Expand Up @@ -214,10 +214,10 @@ void MNNNanoDetEfficientNetLite::generate_bboxes_single_stride(const NanoLiteSca
float y1 = ((cy - t) * s - (float) dh) / ratio; // cy - t y1
float x2 = ((cx + r) * s - (float) dw) / ratio; // cx + r x2
float y2 = ((cy + b) * s - (float) dh) / ratio; // cy + b y2
box.x1 = std::fmax(0.f, x1);
box.y1 = std::fmax(0.f, y1);
box.x2 = std::fmin(img_width, x2);
box.y2 = std::fmin(img_height, y2);
box.x1 = std::max(0.f, x1);
box.y1 = std::max(0.f, y1);
box.x2 = std::min(img_width, x2);
box.y2 = std::min(img_height, y2);
box.score = cls_conf;
box.label = label;
box.label_text = class_names[label];
Expand Down
2 changes: 1 addition & 1 deletion lite/mnn/cv/mnn_rvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace mnncv
public:
explicit MNNRobustVideoMatting(const std::string &_mnn_path,
unsigned int _num_threads = 1,
unsigned int _variant_type = VARIANT::MOBILENETV3); //
unsigned int _variant_type = 0); //
~MNNRobustVideoMatting();

private:
Expand Down
2 changes: 1 addition & 1 deletion lite/mnn/cv/mnn_yolop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void MNNYOLOP::resize_unscale(const cv::Mat &mat, cv::Mat &mat_rs,
// scale ratio (new / old) new_shape(h,w)
float w_r = (float) target_width / (float) img_width;
float h_r = (float) target_height / (float) img_height;
float r = std::fmin(w_r, h_r);
float r = std::min(w_r, h_r);
// compute padding
int new_unpad_w = static_cast<int>((float) img_width * r); // floor
int new_unpad_h = static_cast<int>((float) img_height * r); // floor
Expand Down
4 changes: 2 additions & 2 deletions lite/mnn/cv/mnn_yolox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ void MNNYoloX::generate_bboxes(std::vector<types::Boxf> &bbox_collection,

float cx = (dx + (float) grid0) * (float) stride;
float cy = (dy + (float) grid1) * (float) stride;
float w = std::expf(dw) * (float) stride;
float h = std::expf(dh) * (float) stride;
float w = std::exp(dw) * (float) stride;
float h = std::exp(dh) * (float) stride;

types::Boxf box;
box.x1 = (cx - w / 2.f) * scale_width;
Expand Down
10 changes: 5 additions & 5 deletions lite/ncnn/cv/ncnn_nanodet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void NCNNNanoDet::resize_unscale(const cv::Mat &mat, cv::Mat &mat_rs,
// scale ratio (new / old) new_shape(h,w)
float w_r = (float) target_width / (float) img_width;
float h_r = (float) target_height / (float) img_height;
float r = std::fmin(w_r, h_r);
float r = std::min(w_r, h_r);
// compute padding
int new_unpad_w = static_cast<int>((float) img_width * r); // floor
int new_unpad_h = static_cast<int>((float) img_height * r); // floor
Expand Down Expand Up @@ -206,10 +206,10 @@ void NCNNNanoDet::generate_bboxes_single_stride(const NanoScaleParams &scale_par
float y1 = ((cy - t) * s - (float) dh) / ratio; // cy - t y1
float x2 = ((cx + r) * s - (float) dw) / ratio; // cx + r x2
float y2 = ((cy + b) * s - (float) dh) / ratio; // cy + b y2
box.x1 = std::fmax(0.f, x1);
box.y1 = std::fmax(0.f, y1);
box.x2 = std::fmin(img_width, x2);
box.y2 = std::fmin(img_height, y2);
box.x1 = std::max(0.f, x1);
box.y1 = std::max(0.f, y1);
box.x2 = std::min(img_width, x2);
box.y2 = std::min(img_height, y2);
box.score = cls_conf;
box.label = label;
box.label_text = class_names[label];
Expand Down
10 changes: 5 additions & 5 deletions lite/ncnn/cv/ncnn_nanodet_depreciated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void NCNNNanoDetDepreciated::resize_unscale(const cv::Mat &mat, cv::Mat &mat_rs,
// scale ratio (new / old) new_shape(h,w)
float w_r = (float) target_width / (float) img_width;
float h_r = (float) target_height / (float) img_height;
float r = std::fmin(w_r, h_r);
float r = std::min(w_r, h_r);
// compute padding
int new_unpad_w = static_cast<int>((float) img_width * r); // floor
int new_unpad_h = static_cast<int>((float) img_height * r); // floor
Expand Down Expand Up @@ -220,10 +220,10 @@ void NCNNNanoDetDepreciated::generate_bboxes_single_stride(const NanoDepreciated
float y1 = ((cy - t) * s - (float) dh) / ratio; // cy - t y1
float x2 = ((cx + r) * s - (float) dw) / ratio; // cx + r x2
float y2 = ((cy + b) * s - (float) dh) / ratio; // cy + b y2
box.x1 = std::fmax(0.f, x1);
box.y1 = std::fmax(0.f, y1);
box.x2 = std::fmin(img_width, x2);
box.y2 = std::fmin(img_height, y2);
box.x1 = std::max(0.f, x1);
box.y1 = std::max(0.f, y1);
box.x2 = std::min(img_width, x2);
box.y2 = std::min(img_height, y2);
box.score = cls_conf;
box.label = label;
box.label_text = class_names[label];
Expand Down
10 changes: 5 additions & 5 deletions lite/ncnn/cv/ncnn_nanodet_efficientnet_lite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void NCNNNanoDetEfficientNetLite::resize_unscale(const cv::Mat &mat, cv::Mat &ma
// scale ratio (new / old) new_shape(h,w)
float w_r = (float) target_width / (float) img_width;
float h_r = (float) target_height / (float) img_height;
float r = std::fmin(w_r, h_r);
float r = std::min(w_r, h_r);
// compute padding
int new_unpad_w = static_cast<int>((float) img_width * r); // floor
int new_unpad_h = static_cast<int>((float) img_height * r); // floor
Expand Down Expand Up @@ -206,10 +206,10 @@ void NCNNNanoDetEfficientNetLite::generate_bboxes_single_stride(const NanoLiteSc
float y1 = ((cy - t) * s - (float) dh) / ratio; // cy - t y1
float x2 = ((cx + r) * s - (float) dw) / ratio; // cx + r x2
float y2 = ((cy + b) * s - (float) dh) / ratio; // cy + b y2
box.x1 = std::fmax(0.f, x1);
box.y1 = std::fmax(0.f, y1);
box.x2 = std::fmin(img_width, x2);
box.y2 = std::fmin(img_height, y2);
box.x1 = std::max(0.f, x1);
box.y1 = std::max(0.f, y1);
box.x2 = std::min(img_width, x2);
box.y2 = std::min(img_height, y2);
box.score = cls_conf;
box.label = label;
box.label_text = class_names[label];
Expand Down
10 changes: 5 additions & 5 deletions lite/ncnn/cv/ncnn_nanodet_efficientnet_lite_depreciated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void NCNNNanoDetEfficientNetLiteDepreciated::resize_unscale(
// scale ratio (new / old) new_shape(h,w)
float w_r = (float) target_width / (float) img_width;
float h_r = (float) target_height / (float) img_height;
float r = std::fmin(w_r, h_r);
float r = std::min(w_r, h_r);
// compute padding
int new_unpad_w = static_cast<int>((float) img_width * r); // floor
int new_unpad_h = static_cast<int>((float) img_height * r); // floor
Expand Down Expand Up @@ -226,10 +226,10 @@ void NCNNNanoDetEfficientNetLiteDepreciated::generate_bboxes_single_stride(
float y1 = ((cy - t) * s - (float) dh) / ratio; // cy - t y1
float x2 = ((cx + r) * s - (float) dw) / ratio; // cx + r x2
float y2 = ((cy + b) * s - (float) dh) / ratio; // cy + b y2
box.x1 = std::fmax(0.f, x1);
box.y1 = std::fmax(0.f, y1);
box.x2 = std::fmin(img_width, x2);
box.y2 = std::fmin(img_height, y2);
box.x1 = std::max(0.f, x1);
box.y1 = std::max(0.f, y1);
box.x2 = std::min(img_width, x2);
box.y2 = std::min(img_height, y2);
box.score = cls_conf;
box.label = label;
box.label_text = class_names[label];
Expand Down
2 changes: 1 addition & 1 deletion lite/ncnn/cv/ncnn_rvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace ncnncv
unsigned int _num_threads = 1,
int _input_height = 480,
int _input_width = 640,
unsigned int _variant_type = VARIANT::MOBILENETV3); //
unsigned int _variant_type = 0); //
~NCNNRobustVideoMatting() override = default;

private:
Expand Down
4 changes: 2 additions & 2 deletions lite/ort/cv/efficientdet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ void EfficientDet::generate_bboxes(std::vector<types::Boxf> &bbox_collection,

float cx = dx * wa + cxa;
float cy = dy * ha + cya;
float w = std::expf(dw) * wa;
float h = std::expf(dh) * ha;
float w = std::exp(dw) * wa;
float h = std::exp(dh) * ha;

types::Boxf box;
box.x1 = (cx - w / 2.f) * scale_width;
Expand Down
4 changes: 2 additions & 2 deletions lite/ort/cv/efficientdet_d7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ void EfficientDetD7::generate_bboxes(std::vector<types::Boxf> &bbox_collection,

float cx = dx * wa + cxa;
float cy = dy * ha + cya;
float w = std::expf(dw) * wa;
float h = std::expf(dh) * ha;
float w = std::exp(dw) * wa;
float h = std::exp(dh) * ha;

types::Boxf box;
box.x1 = (cx - w / 2.f) * scale_width;
Expand Down
4 changes: 2 additions & 2 deletions lite/ort/cv/efficientdet_d8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ void EfficientDetD8::generate_bboxes(std::vector<types::Boxf> &bbox_collection,

float cx = dx * wa + cxa;
float cy = dy * ha + cya;
float w = std::expf(dw) * wa;
float h = std::expf(dh) * ha;
float w = std::exp(dw) * wa;
float h = std::exp(dh) * ha;

types::Boxf box;
box.x1 = (cx - w / 2.f) * scale_width;
Expand Down
4 changes: 2 additions & 2 deletions lite/ort/cv/face_landmarks_1000.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ void FaceLandmark1000::detect(const cv::Mat &mat, types::Landmarks &landmarks)
float x = landmarks_norm.At<float>({0, i});
float y = landmarks_norm.At<float>({0, i + 1});

x = std::fmin(std::fmax(0., x), 1.0f);
y = std::fmin(std::fmax(0., y), 1.0f);
x = std::min(std::max(0.f, x), 1.0f);
y = std::min(std::max(0.f, y), 1.0f);

landmarks.points.push_back(cv::Point2f(x * img_width, y * img_height));
}
Expand Down
8 changes: 4 additions & 4 deletions lite/ort/cv/faceboxes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ void FaceBoxes::generate_anchors(const int target_height,
{
feature_maps.push_back(
{
(int) std::ceilf((float) target_height / (float) step),
(int) std::ceilf((float) target_width / (float) step)
(int) std::ceil((float) target_height / (float) step),
(int) std::ceil((float) target_width / (float) step)
} // ceil
);
}
Expand Down Expand Up @@ -166,8 +166,8 @@ void FaceBoxes::generate_bboxes(std::vector<types::Boxf> &bbox_collection,
// ref: https://github.com/zisianw/FaceBoxes.PyTorch/blob/master/utils/box_utils.py
float cx = prior_cx + dx * variance[0] * prior_s_kx;
float cy = prior_cy + dy * variance[0] * prior_s_ky;
float w = prior_s_kx * std::expf(dw * variance[1]);
float h = prior_s_ky * std::expf(dh * variance[1]); // norm coor (0.,1.)
float w = prior_s_kx * std::exp(dw * variance[1]);
float h = prior_s_ky * std::exp(dh * variance[1]); // norm coor (0.,1.)

types::Boxf box;
box.x1 = (cx - w / 2.f) * img_width;
Expand Down
4 changes: 2 additions & 2 deletions lite/ort/cv/mobilenetv2_68.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ void MobileNetV268::detect(const cv::Mat &mat, types::Landmarks &landmarks)
float x = landmarks_norm.At<float>({0, i});
float y = landmarks_norm.At<float>({0, i + 1});

x = std::fmin(std::fmax(0., x), 1.0f);
y = std::fmin(std::fmax(0., y), 1.0f);
x = std::min(std::max(0.f, x), 1.0f);
y = std::min(std::max(0.f, y), 1.0f);

landmarks.points.push_back(cv::Point2f(x * img_width, y * img_height));
}
Expand Down
4 changes: 2 additions & 2 deletions lite/ort/cv/mobilenetv2_se_68.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ void MobileNetV2SE68::detect(const cv::Mat &mat, types::Landmarks &landmarks)
float x = landmarks_norm.At<float>({0, i});
float y = landmarks_norm.At<float>({0, i + 1});

x = std::fmin(std::fmax(0., x), 1.0f);
y = std::fmin(std::fmax(0., y), 1.0f);
x = std::min(std::max(0.f, x), 1.0f);
y = std::min(std::max(0.f, y), 1.0f);

landmarks.points.push_back(cv::Point2f(x * img_width, y * img_height));
}
Expand Down
10 changes: 5 additions & 5 deletions lite/ort/cv/nanodet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void NanoDet::resize_unscale(const cv::Mat &mat, cv::Mat &mat_rs,
// scale ratio (new / old) new_shape(h,w)
float w_r = (float) target_width / (float) img_width;
float h_r = (float) target_height / (float) img_height;
float r = std::fmin(w_r, h_r);
float r = std::min(w_r, h_r);
// compute padding
int new_unpad_w = static_cast<int>((float) img_width * r); // floor
int new_unpad_h = static_cast<int>((float) img_height * r); // floor
Expand Down Expand Up @@ -197,10 +197,10 @@ void NanoDet::generate_bboxes_single_stride(const NanoScaleParams &scale_params,
float y1 = ((cy - t) * s - (float) dh) / ratio; // cy - t y1
float x2 = ((cx + r) * s - (float) dw) / ratio; // cx + r x2
float y2 = ((cy + b) * s - (float) dh) / ratio; // cy + b y2
box.x1 = std::fmax(0.f, x1);
box.y1 = std::fmax(0.f, y1);
box.x2 = std::fmin(img_width, x2);
box.y2 = std::fmin(img_height, y2);
box.x1 = std::max(0.f, x1);
box.y1 = std::max(0.f, y1);
box.x2 = std::min(img_width, x2);
box.y2 = std::min(img_height, y2);
box.score = cls_conf;
box.label = label;
box.label_text = class_names[label];
Expand Down
10 changes: 5 additions & 5 deletions lite/ort/cv/nanodet_efficientnet_lite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void NanoDetEfficientNetLite::resize_unscale(const cv::Mat &mat, cv::Mat &mat_rs
// scale ratio (new / old) new_shape(h,w)
float w_r = (float) target_width / (float) img_width;
float h_r = (float) target_height / (float) img_height;
float r = std::fmin(w_r, h_r);
float r = std::min(w_r, h_r);
// compute padding
int new_unpad_w = static_cast<int>((float) img_width * r); // floor
int new_unpad_h = static_cast<int>((float) img_height * r); // floor
Expand Down Expand Up @@ -197,10 +197,10 @@ void NanoDetEfficientNetLite::generate_bboxes_single_stride(const NanoLiteScaleP
float y1 = ((cy - t) * s - (float) dh) / ratio; // cy - t y1
float x2 = ((cx + r) * s - (float) dw) / ratio; // cx + r x2
float y2 = ((cy + b) * s - (float) dh) / ratio; // cy + b y2
box.x1 = std::fmax(0.f, x1);
box.y1 = std::fmax(0.f, y1);
box.x2 = std::fmin(img_width, x2);
box.y2 = std::fmin(img_height, y2);
box.x1 = std::max(0.f, x1);
box.y1 = std::max(0.f, y1);
box.x2 = std::min(img_width, x2);
box.y2 = std::min(img_height, y2);
box.score = cls_conf;
box.label = label;
box.label_text = class_names[label];
Expand Down
4 changes: 2 additions & 2 deletions lite/ort/cv/pfld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ void PFLD::detect(const cv::Mat &mat, types::Landmarks &landmarks)
float x = landmarks_norm.At<float>({0, i});
float y = landmarks_norm.At<float>({0, i + 1});

x = std::fmin(std::fmax(0., x), 1.0f);
y = std::fmin(std::fmax(0., y), 1.0f);
x = std::min(std::max(0.f, x), 1.0f);
y = std::min(std::max(0.f, y), 1.0f);

landmarks.points.push_back(cv::Point2f(x * img_width, y * img_height));
}
Expand Down
4 changes: 2 additions & 2 deletions lite/ort/cv/pfld68.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ void PFLD68::detect(const cv::Mat &mat, types::Landmarks &landmarks)
float x = landmarks_norm.At<float>({0, i});
float y = landmarks_norm.At<float>({0, i + 1});

x = std::fmin(std::fmax(0., x), 1.0f);
y = std::fmin(std::fmax(0., y), 1.0f);
x = std::min(std::max(0.f, x), 1.0f);
y = std::min(std::max(0.f, y), 1.0f);

landmarks.points.push_back(cv::Point2f(x * img_width, y * img_height));
}
Expand Down
4 changes: 2 additions & 2 deletions lite/ort/cv/pfld98.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ void PFLD98::detect(const cv::Mat &mat, types::Landmarks &landmarks)
float x = landmarks_norm.At<float>({0, i});
float y = landmarks_norm.At<float>({0, i + 1});

x = std::fmin(std::fmax(0., x), 1.0f);
y = std::fmin(std::fmax(0., y), 1.0f);
x = std::min(std::max(0.f, x), 1.0f);
y = std::min(std::max(0.f, y), 1.0f);

landmarks.points.push_back(cv::Point2f(x * img_width, y * img_height));
}
Expand Down
8 changes: 4 additions & 4 deletions lite/ort/cv/retinaface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ void RetinaFace::generate_anchors(const int target_height,
{
feature_maps.push_back(
{
(int) std::ceilf((float) target_height / (float) step),
(int) std::ceilf((float) target_width / (float) step)
(int) std::ceil((float) target_height / (float) step),
(int) std::ceil((float) target_width / (float) step)
} // ceil
);
}
Expand Down Expand Up @@ -131,8 +131,8 @@ void RetinaFace::generate_bboxes(std::vector<types::Boxf> &bbox_collection,
// ref: https://github.com/biubug6/Pytorch_Retinaface/blob/master/utils/box_utils.py
float cx = prior_cx + dx * variance[0] * prior_s_kx;
float cy = prior_cy + dy * variance[0] * prior_s_ky;
float w = prior_s_kx * std::expf(dw * variance[1]);
float h = prior_s_ky * std::expf(dh * variance[1]); // norm coor (0.,1.)
float w = prior_s_kx * std::exp(dw * variance[1]);
float h = prior_s_ky * std::exp(dh * variance[1]); // norm coor (0.,1.)

types::Boxf box;
box.x1 = (cx - w / 2.f) * img_width;
Expand Down
2 changes: 1 addition & 1 deletion lite/ort/cv/tiny_yolov3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ std::vector<Ort::Value> TinyYoloV3::transform(const std::vector<cv::Mat> &mats)
const unsigned int image_height = canvas.rows;
const unsigned int image_width = canvas.cols;

const float scale = std::fmin(
const float scale = std::min(
(float) input_width / (float) image_width,
(float) input_height / (float) image_height
);
Expand Down
2 changes: 1 addition & 1 deletion lite/ort/cv/yolop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void YOLOP::resize_unscale(const cv::Mat &mat, cv::Mat &mat_rs,
// scale ratio (new / old) new_shape(h,w)
float w_r = (float) target_width / (float) img_width;
float h_r = (float) target_height / (float) img_height;
float r = std::fmin(w_r, h_r);
float r = std::min(w_r, h_r);
// compute padding
int new_unpad_w = static_cast<int>((float) img_width * r); // floor
int new_unpad_h = static_cast<int>((float) img_height * r); // floor
Expand Down
2 changes: 1 addition & 1 deletion lite/ort/cv/yolov3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ std::vector<Ort::Value> YoloV3::transform(const std::vector<cv::Mat> &mats)
const unsigned int image_height = canvas.rows;
const unsigned int image_width = canvas.cols;

const float scale = std::fmin(
const float scale = std::min(
(float) input_width / (float) image_width,
(float) input_height / (float) image_height
);
Expand Down
Loading