Commit daa24484 authored by Alexander Alekhin's avatar Alexander Alekhin

text: filter CNN detection results

- instead of validation checks
parent 8fde8d74
...@@ -29,26 +29,29 @@ protected: ...@@ -29,26 +29,29 @@ protected:
{ {
for(int k = 0; k < nbrTextBoxes; k++) for(int k = 0; k < nbrTextBoxes; k++)
{ {
float x_min = buffer[k*nCol + 3]*inputShape.width; float confidence_ = buffer[k*nCol + 2];
float y_min = buffer[k*nCol + 4]*inputShape.height; if (confidence_ <= FLT_EPSILON) continue;
float x_max = buffer[k*nCol + 5]*inputShape.width; float x_min_f = buffer[k*nCol + 3]*inputShape.width;
float y_max = buffer[k*nCol + 6]*inputShape.height; float y_min_f = buffer[k*nCol + 4]*inputShape.height;
CV_CheckLT(x_min, x_max, ""); float x_max_f = buffer[k*nCol + 5]*inputShape.width;
CV_CheckLT(y_min, y_max, ""); float y_max_f = buffer[k*nCol + 6]*inputShape.height;
x_min = std::max(0.f, x_min); int x_min = cvRound(std::max(0.f, x_min_f));
y_min = std::max(0.f, y_min); int y_min = cvRound(std::max(0.f, y_min_f));
x_max = std::min(inputShape.width - 1.f, x_max); int x_max = std::min(inputShape.width - 1, cvRound(x_max_f));
y_max = std::min(inputShape.height - 1.f, y_max); int y_max = std::min(inputShape.height - 1, cvRound(y_max_f));
int wd = cvRound(x_max - x_min); if (x_min >= x_max) continue;
int ht = cvRound(y_max - y_min); if (y_min >= y_max) continue;
Bbox.push_back(Rect(cvRound(x_min), cvRound(y_min), wd, ht)); int wd = x_max - x_min;
confidence.push_back(buffer[k*nCol + 2]); int ht = y_max - y_min;
Bbox.push_back(Rect(x_min, y_min, wd, ht));
confidence.push_back(confidence_);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment