|
|
|
@ -871,13 +871,36 @@ void diounms_sort(detection *dets, int total, int classes, float thresh, NMS_KIN |
|
|
|
|
for (i = 0; i < total; ++i) { |
|
|
|
|
dets[i].sort_class = k; |
|
|
|
|
} |
|
|
|
|
qsort(dets, total, sizeof(detection), nms_comparator); |
|
|
|
|
for (i = 0; i < total; ++i) { |
|
|
|
|
qsort(dets, total, sizeof(detection), nms_comparator_v3); |
|
|
|
|
for (i = 0; i < total; ++i) |
|
|
|
|
{ |
|
|
|
|
if (dets[i].prob[k] == 0) continue; |
|
|
|
|
box a = dets[i].bbox; |
|
|
|
|
for (j = i + 1; j < total; ++j) { |
|
|
|
|
box b = dets[j].bbox; |
|
|
|
|
if (box_iou(a, b) > thresh && nms_kind == GREEDY_NMS) { |
|
|
|
|
if (box_iou(a, b) > thresh && nms_kind == CORNERS_NMS) |
|
|
|
|
{ |
|
|
|
|
float sum_prob = pow(dets[i].prob[k], 2) + pow(dets[j].prob[k], 2); |
|
|
|
|
float alpha_prob = pow(dets[i].prob[k], 2) / sum_prob; |
|
|
|
|
float beta_prob = pow(dets[j].prob[k], 2) / sum_prob; |
|
|
|
|
//dets[i].bbox.x = (dets[i].bbox.x*alpha_prob + dets[j].bbox.x*beta_prob);
|
|
|
|
|
//dets[i].bbox.y = (dets[i].bbox.y*alpha_prob + dets[j].bbox.y*beta_prob);
|
|
|
|
|
//dets[i].bbox.w = (dets[i].bbox.w*alpha_prob + dets[j].bbox.w*beta_prob);
|
|
|
|
|
//dets[i].bbox.h = (dets[i].bbox.h*alpha_prob + dets[j].bbox.h*beta_prob);
|
|
|
|
|
/*
|
|
|
|
|
if (dets[j].points == YOLO_CENTER && (dets[i].points & dets[j].points) == 0) { |
|
|
|
|
dets[i].bbox.x = (dets[i].bbox.x*alpha_prob + dets[j].bbox.x*beta_prob); |
|
|
|
|
dets[i].bbox.y = (dets[i].bbox.y*alpha_prob + dets[j].bbox.y*beta_prob); |
|
|
|
|
} |
|
|
|
|
else if ((dets[i].points & dets[j].points) == 0) { |
|
|
|
|
dets[i].bbox.w = (dets[i].bbox.w*alpha_prob + dets[j].bbox.w*beta_prob); |
|
|
|
|
dets[i].bbox.h = (dets[i].bbox.h*alpha_prob + dets[j].bbox.h*beta_prob); |
|
|
|
|
} |
|
|
|
|
dets[i].points |= dets[j].points; |
|
|
|
|
*/ |
|
|
|
|
dets[j].prob[k] = 0; |
|
|
|
|
} |
|
|
|
|
else if (box_iou(a, b) > thresh && nms_kind == GREEDY_NMS) { |
|
|
|
|
dets[j].prob[k] = 0; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
@ -886,6 +909,9 @@ void diounms_sort(detection *dets, int total, int classes, float thresh, NMS_KIN |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//if ((nms_kind == CORNERS_NMS) && (dets[i].points != (YOLO_CENTER | YOLO_LEFT_TOP | YOLO_RIGHT_BOTTOM)))
|
|
|
|
|
// dets[i].prob[k] = 0;
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|