Skip to content

Commit fce8d8e

Browse files
committed
Merge pull request opencv#19074 from alalek:dnn_test_tolerance_east
2 parents de38500 + 8ff27a0 commit fce8d8e

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

modules/dnn/test/test_model.cpp

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,15 @@ class Test_Model : public DNNTestLayer
209209
normAssertTextDetections(gt, contours, "", 0.05f);
210210
}
211211

212-
void testTextDetectionModelByEAST(const std::string& weights, const std::string& cfg,
213-
const std::string& imgPath, const std::vector<RotatedRect>& gt,
214-
float confThresh, float nmsThresh,
215-
const Size& size = {-1, -1}, Scalar mean = Scalar(),
216-
double scale = 1.0, bool swapRB = false, bool crop = false)
212+
void testTextDetectionModelByEAST(
213+
const std::string& weights, const std::string& cfg,
214+
const std::string& imgPath, const std::vector<RotatedRect>& gt,
215+
float confThresh, float nmsThresh,
216+
const Size& size = {-1, -1}, Scalar mean = Scalar(),
217+
double scale = 1.0, bool swapRB = false, bool crop = false,
218+
double eps_center = 5/*pixels*/, double eps_size = 5/*pixels*/, double eps_angle = 1
219+
)
217220
{
218-
const double EPS_PIXELS = 3;
219-
220221
checkBackend();
221222

222223
Mat frame = imread(imgPath);
@@ -255,11 +256,11 @@ class Test_Model : public DNNTestLayer
255256
waitKey(0);
256257
#endif
257258
const RotatedRect& gtBox = gt[i];
258-
EXPECT_NEAR(box.center.x, gtBox.center.x, EPS_PIXELS);
259-
EXPECT_NEAR(box.center.y, gtBox.center.y, EPS_PIXELS);
260-
EXPECT_NEAR(box.size.width, gtBox.size.width, EPS_PIXELS);
261-
EXPECT_NEAR(box.size.height, gtBox.size.height, EPS_PIXELS);
262-
EXPECT_NEAR(box.angle, gtBox.angle, 1);
259+
EXPECT_NEAR(box.center.x, gtBox.center.x, eps_center);
260+
EXPECT_NEAR(box.center.y, gtBox.center.y, eps_center);
261+
EXPECT_NEAR(box.size.width, gtBox.size.width, eps_size);
262+
EXPECT_NEAR(box.size.height, gtBox.size.height, eps_size);
263+
EXPECT_NEAR(box.angle, gtBox.angle, eps_angle);
263264
}
264265
}
265266
};
@@ -642,9 +643,6 @@ TEST_P(Test_Model, TextDetectionByDB)
642643

643644
TEST_P(Test_Model, TextDetectionByEAST)
644645
{
645-
if (target == DNN_TARGET_OPENCL_FP16)
646-
applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
647-
648646
std::string imgPath = _tf("text_det_test2.jpg");
649647
std::string weightPath = _tf("frozen_east_text_detection.pb", false);
650648

@@ -663,7 +661,20 @@ TEST_P(Test_Model, TextDetectionByEAST)
663661
float confThresh = 0.5;
664662
float nmsThresh = 0.4;
665663

666-
testTextDetectionModelByEAST(weightPath, "", imgPath, gt, confThresh, nmsThresh, size, mean, scale, swapRB);
664+
double eps_center = 5/*pixels*/;
665+
double eps_size = 5/*pixels*/;
666+
double eps_angle = 1;
667+
668+
if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_CUDA_FP16 || target == DNN_TARGET_MYRIAD)
669+
{
670+
eps_center = 10;
671+
eps_size = 25;
672+
eps_angle = 3;
673+
}
674+
675+
testTextDetectionModelByEAST(weightPath, "", imgPath, gt, confThresh, nmsThresh, size, mean, scale, swapRB, false/*crop*/,
676+
eps_center, eps_size, eps_angle
677+
);
667678
}
668679

669680
INSTANTIATE_TEST_CASE_P(/**/, Test_Model, dnnBackendsAndTargets());

0 commit comments

Comments
 (0)