| |
|
| | # OpenCV >= 4.5 |
| |
|
| | #include <iostream> |
| | #include <fstream> |
| |
|
| | #include <opencv2/imgproc.hpp> |
| | #include <opencv2/highgui.hpp> |
| | #include <opencv2/dnn.hpp> |
| |
|
| | using namespace cv; |
| | using namespace cv::dnn; |
| |
|
| | |
| | TextDetectionModel_DB model("./DB_IC15_resnet50.onnx"); |
| | |
| | |
| | float binThresh = 0.3; |
| | float polyThresh = 0.5; |
| | uint maxCandidates = 200; |
| | double unclipRatio = 2.0; |
| | model.setBinaryThreshold(binThresh) |
| | .setPolygonThreshold(polyThresh) |
| | .setMaxCandidates(maxCandidates) |
| | .setUnclipRatio(unclipRatio) |
| | ; |
| | |
| | |
| | double scale = 1.0 / 255.0; |
| | Scalar mean = Scalar(122.67891434, 116.66876762, 104.00698793); |
| | |
| | |
| | Size inputSize = Size(736, 736); |
| | |
| | model.setInputParams(scale, inputSize, mean); |
| |
|
| |
|
| | std::vector<std::vector<Point>> detResults; |
| | model.detect(detResults); |
| | |
| | |
| | polylines(frame, results, true, Scalar(0, 255, 0), 2); |
| | imshow("Text Detection", image); |
| | waitKey(); |
| |
|
| |
|