1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

add scale factor to DB demo.

This commit is contained in:
zihaomu
2023-04-30 22:03:21 +08:00
parent e3e1f704a4
commit 8be93a6de7
4 changed files with 70 additions and 18 deletions
+22 -8
View File
@@ -153,8 +153,8 @@ public:
const std::string& imgPath, const std::vector<std::vector<Point>>& gt,
float binThresh, float polyThresh,
uint maxCandidates, double unclipRatio,
const Size& size = {-1, -1}, Scalar mean = Scalar(),
double scale = 1.0, bool swapRB = false, bool crop = false)
const Size& size = {-1, -1}, Scalar mean = Scalar(), Scalar scale = Scalar::all(1.0),
double boxes_iou_diff = 0.05, bool swapRB = false, bool crop = false)
{
checkBackend();
@@ -197,7 +197,7 @@ public:
imshow("result", result); // imwrite("result.png", result);
waitKey(0);
#endif
normAssertTextDetections(gt, contours, "", 0.05f);
normAssertTextDetections(gt, contours, "", boxes_iou_diff);
// 2. Check quadrangle-based API
// std::vector< std::vector<Point> > contours;
@@ -209,7 +209,7 @@ public:
imshow("result_contours", result); // imwrite("result_contours.png", result);
waitKey(0);
#endif
normAssertTextDetections(gt, contours, "", 0.05f);
normAssertTextDetections(gt, contours, "", boxes_iou_diff);
}
void testTextDetectionModelByEAST(
@@ -743,7 +743,8 @@ TEST_P(Test_Model, TextDetectionByDB)
applyTestTag(CV_TEST_TAG_DNN_SKIP_OPENCL_FP16);
std::string imgPath = _tf("text_det_test1.png");
std::string weightPath = _tf("onnx/models/DB_TD500_resnet50.onnx", false);
std::string weightPathDB = _tf("onnx/models/DB_TD500_resnet50.onnx", false);
std::string weightPathPPDB = _tf("onnx/models/PP_OCRv3_DB_text_det.onnx", false);
// GroundTruth
std::vector<std::vector<Point>> gt = {
@@ -752,15 +753,28 @@ TEST_P(Test_Model, TextDetectionByDB)
};
Size size{736, 736};
double scale = 1.0 / 255.0;
Scalar mean = Scalar(122.67891434, 116.66876762, 104.00698793);
Scalar scaleDB = Scalar::all(1.0 / 255.0);
Scalar meanDB = Scalar(122.67891434, 116.66876762, 104.00698793);
// new mean and stddev
Scalar meanPPDB = Scalar(123.675, 116.28, 103.53);
Scalar stddevPPDB = Scalar(0.229, 0.224, 0.225);
Scalar scalePPDB = scaleDB / stddevPPDB;
float binThresh = 0.3;
float polyThresh = 0.5;
uint maxCandidates = 200;
double unclipRatio = 2.0;
testTextDetectionModelByDB(weightPath, "", imgPath, gt, binThresh, polyThresh, maxCandidates, unclipRatio, size, mean, scale);
{
SCOPED_TRACE("Original DB");
testTextDetectionModelByDB(weightPathDB, "", imgPath, gt, binThresh, polyThresh, maxCandidates, unclipRatio, size, meanDB, scaleDB, 0.05f);
}
{
SCOPED_TRACE("PP-OCRDBv3");
testTextDetectionModelByDB(weightPathPPDB, "", imgPath, gt, binThresh, polyThresh, maxCandidates, unclipRatio, size, meanPPDB, scalePPDB, 0.21f);
}
}
TEST_P(Test_Model, TextDetectionByEAST)