Skip to content

Commit 5bace76

Browse files
committed
fix some
1 parent 48ec21b commit 5bace76

File tree

1 file changed

+11
-9
lines changed
  • yolox_ros_cpp/yolox_cpp/include/yolox_cpp

1 file changed

+11
-9
lines changed

yolox_ros_cpp/yolox_cpp/include/yolox_cpp/core.hpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ namespace yolox_cpp
1515
cv::Rect_<float> rect;
1616
int label;
1717
float prob;
18+
bool operator<(const Object &right) const {
19+
return prob < right.prob;
20+
}
1821
};
1922

2023
struct GridAndStride
@@ -124,7 +127,7 @@ namespace yolox_cpp
124127
}
125128
cv::merge(img_f32_split, img_f32);
126129
}
127-
blob_data = reinterpret_cast<float *>(img_f32.data);
130+
memcpy(blob_data, img_f32.data, img.rows * img.cols * channels * sizeof(float));
128131
}
129132

130133
void generate_grids_and_stride(const int target_w, const int target_h, const std::vector<int> &strides, std::vector<GridAndStride> &grid_strides)
@@ -214,7 +217,7 @@ namespace yolox_cpp
214217
const Object &a = faceobjects[i];
215218
const int picked_size = picked.size();
216219

217-
int keep = 1;
220+
bool keep = true;
218221
for (int j = 0; j < picked_size; ++j)
219222
{
220223
const Object &b = faceobjects[picked[j]];
@@ -224,7 +227,10 @@ namespace yolox_cpp
224227
const float union_area = areas[i] + areas[picked[j]] - inter_area;
225228
// float IoU = inter_area / union_area
226229
if (inter_area / union_area > nms_threshold)
227-
keep = 0;
230+
{
231+
keep = false;
232+
break;
233+
}
228234
}
229235

230236
if (keep)
@@ -240,12 +246,8 @@ namespace yolox_cpp
240246
std::vector<Object> proposals;
241247
generate_yolox_proposals(grid_strides, prob, bbox_conf_thresh, proposals);
242248

243-
std::sort(
244-
proposals.begin(), proposals.end(),
245-
[](const Object &a, const Object &b)
246-
{
247-
return a.prob > b.prob; // descent
248-
});
249+
// descent
250+
std::sort(std::rbegin(proposals), std::rend(proposals));
249251

250252
std::vector<int> picked;
251253
nms_sorted_bboxes(proposals, picked, nms_thresh_);

0 commit comments

Comments
 (0)