@@ -29,26 +29,29 @@ class TextDetectorCNNImpl : public TextDetectorCNN
29
29
{
30
30
for (int k = 0 ; k < nbrTextBoxes; k++)
31
31
{
32
- float x_min = buffer[k*nCol + 3 ]*inputShape. width ;
33
- float y_min = buffer[k*nCol + 4 ]*inputShape. height ;
32
+ float confidence_ = buffer[k*nCol + 2 ] ;
33
+ if (confidence_ <= FLT_EPSILON) continue ;
34
34
35
- float x_max = buffer[k*nCol + 5 ]*inputShape.width ;
36
- float y_max = buffer[k*nCol + 6 ]*inputShape.height ;
35
+ float x_min_f = buffer[k*nCol + 3 ]*inputShape.width ;
36
+ float y_min_f = buffer[k*nCol + 4 ]*inputShape.height ;
37
37
38
- CV_CheckLT (x_min, x_max, " " ) ;
39
- CV_CheckLT (y_min, y_max, " " ) ;
38
+ float x_max_f = buffer[k*nCol + 5 ]*inputShape. width ;
39
+ float y_max_f = buffer[k*nCol + 6 ]*inputShape. height ;
40
40
41
- x_min = std::max (0 .f , x_min );
42
- y_min = std::max (0 .f , y_min );
41
+ int x_min = cvRound ( std::max (0 .f , x_min_f) );
42
+ int y_min = cvRound ( std::max (0 .f , y_min_f) );
43
43
44
- x_max = std::min (inputShape.width - 1 . f , x_max );
45
- y_max = std::min (inputShape.height - 1 . f , y_max );
44
+ int x_max = std::min (inputShape.width - 1 , cvRound (x_max_f) );
45
+ int y_max = std::min (inputShape.height - 1 , cvRound (y_max_f) );
46
46
47
- int wd = cvRound ( x_max - x_min) ;
48
- int ht = cvRound ( y_max - y_min) ;
47
+ if (x_min >= x_max) continue ;
48
+ if (y_min >= y_max) continue ;
49
49
50
- Bbox.push_back (Rect (cvRound (x_min), cvRound (y_min), wd, ht));
51
- confidence.push_back (buffer[k*nCol + 2 ]);
50
+ int wd = x_max - x_min;
51
+ int ht = y_max - y_min;
52
+
53
+ Bbox.push_back (Rect (x_min, y_min, wd, ht));
54
+ confidence.push_back (confidence_);
52
55
}
53
56
}
54
57
0 commit comments