Wanli
commited on
Commit
·
cc3d40f
1
Parent(s):
b5f00c2
remove text detection DB (#221)
Browse files
demo.cpp
CHANGED
@@ -41,10 +41,10 @@ std::string keys =
|
|
41 |
"4: CANN + NPU}";
|
42 |
|
43 |
|
44 |
-
class
|
45 |
public:
|
46 |
|
47 |
-
|
48 |
float polyThresh = 0.5, int maxCand = 200, double unRatio = 2.0,
|
49 |
dnn::Backend bId = DNN_BACKEND_DEFAULT, dnn::Target tId = DNN_TARGET_CPU) : modelPath(modPath), inputSize(inSize), binaryThreshold(binThresh),
|
50 |
polygonThreshold(polyThresh), maxCandidates(maxCand), unclipRatio(unRatio),
|
@@ -215,7 +215,7 @@ int main(int argc, char** argv)
|
|
215 |
bool save = parser.get<bool>("save");
|
216 |
bool viz = parser.get<float>("viz");
|
217 |
|
218 |
-
|
219 |
CRNN recognizer(modelPath, backendTargetPairs[backendTargetid].first, backendTargetPairs[backendTargetid].second);
|
220 |
//! [Open a video file or an image file or a camera stream]
|
221 |
VideoCapture cap;
|
@@ -232,9 +232,13 @@ int main(int argc, char** argv)
|
|
232 |
cap >> originalImage;
|
233 |
if (originalImage.empty())
|
234 |
{
|
235 |
-
|
236 |
-
|
237 |
-
|
|
|
|
|
|
|
|
|
238 |
}
|
239 |
int originalW = originalImage.cols;
|
240 |
int originalH = originalImage.rows;
|
|
|
41 |
"4: CANN + NPU}";
|
42 |
|
43 |
|
44 |
+
class PPOCRDet {
|
45 |
public:
|
46 |
|
47 |
+
PPOCRDet(string modPath, Size inSize = Size(736, 736), float binThresh = 0.3,
|
48 |
float polyThresh = 0.5, int maxCand = 200, double unRatio = 2.0,
|
49 |
dnn::Backend bId = DNN_BACKEND_DEFAULT, dnn::Target tId = DNN_TARGET_CPU) : modelPath(modPath), inputSize(inSize), binaryThreshold(binThresh),
|
50 |
polygonThreshold(polyThresh), maxCandidates(maxCand), unclipRatio(unRatio),
|
|
|
215 |
bool save = parser.get<bool>("save");
|
216 |
bool viz = parser.get<float>("viz");
|
217 |
|
218 |
+
PPOCRDet detector("../text_detection_ppocr/text_detection_en_ppocrv3_2023may.onnx", inpSize, binThresh, polyThresh, maxCand, unRatio, backendTargetPairs[backendTargetid].first, backendTargetPairs[backendTargetid].second);
|
219 |
CRNN recognizer(modelPath, backendTargetPairs[backendTargetid].first, backendTargetPairs[backendTargetid].second);
|
220 |
//! [Open a video file or an image file or a camera stream]
|
221 |
VideoCapture cap;
|
|
|
232 |
cap >> originalImage;
|
233 |
if (originalImage.empty())
|
234 |
{
|
235 |
+
if (parser.has("input"))
|
236 |
+
{
|
237 |
+
cout << "Frame is empty" << endl;
|
238 |
+
break;
|
239 |
+
}
|
240 |
+
else
|
241 |
+
continue;
|
242 |
}
|
243 |
int originalW = originalImage.cols;
|
244 |
int originalH = originalImage.rows;
|
demo.py
CHANGED
@@ -12,8 +12,8 @@ import cv2 as cv
|
|
12 |
|
13 |
from crnn import CRNN
|
14 |
|
15 |
-
sys.path.append('../
|
16 |
-
from
|
17 |
|
18 |
# Check OpenCV version
|
19 |
assert cv.__version__ >= "4.8.0", \
|
@@ -65,8 +65,8 @@ if __name__ == '__main__':
|
|
65 |
backend_id = backend_target_pairs[args.backend_target][0]
|
66 |
target_id = backend_target_pairs[args.backend_target][1]
|
67 |
|
68 |
-
# Instantiate
|
69 |
-
detector =
|
70 |
inputSize=[args.width, args.height],
|
71 |
binaryThreshold=0.3,
|
72 |
polygonThreshold=0.5,
|
|
|
12 |
|
13 |
from crnn import CRNN
|
14 |
|
15 |
+
sys.path.append('../text_detection_ppocr')
|
16 |
+
from ppocr_det import PPOCRDet
|
17 |
|
18 |
# Check OpenCV version
|
19 |
assert cv.__version__ >= "4.8.0", \
|
|
|
65 |
backend_id = backend_target_pairs[args.backend_target][0]
|
66 |
target_id = backend_target_pairs[args.backend_target][1]
|
67 |
|
68 |
+
# Instantiate PPOCRDet for text detection
|
69 |
+
detector = PPOCRDet(modelPath='../text_detection_ppocr/text_detection_en_ppocrv3_2023may.onnx',
|
70 |
inputSize=[args.width, args.height],
|
71 |
binaryThreshold=0.3,
|
72 |
polygonThreshold=0.5,
|