Skip to content

Commit 218d282

Browse files
committed
update cpp files
1 parent d06c590 commit 218d282

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

models/text_detection_db/demo.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ std::string keys =
3636
"4: CANN + NPU}";
3737

3838

39-
class DB {
39+
class PPOCRv3DB {
4040
public:
4141

42-
DB(string modPath, Size inSize = Size(736, 736), float binThresh = 0.3,
42+
PPOCRv3DB(string modPath, Size inSize = Size(736, 736), float binThresh = 0.3,
4343
float polyThresh = 0.5, int maxCand = 200, double unRatio = 2.0,
4444
dnn::Backend bId = DNN_BACKEND_DEFAULT, dnn::Target tId = DNN_TARGET_CPU) : modelPath(modPath), inputSize(inSize), binaryThreshold(binThresh),
4545
polygonThreshold(polyThresh), maxCandidates(maxCand), unclipRatio(unRatio),
@@ -115,7 +115,7 @@ int main(int argc, char** argv)
115115
bool save = parser.get<bool>("save");
116116
bool viz = parser.get<float>("viz");
117117

118-
DB model(modelName, inpSize, binThresh, polyThresh, maxCand, unRatio, backendTargetPairs[backendTargetid].first, backendTargetPairs[backendTargetid].second);
118+
PPOCRv3DB model(modelName, inpSize, binThresh, polyThresh, maxCand, unRatio, backendTargetPairs[backendTargetid].first, backendTargetPairs[backendTargetid].second);
119119

120120
//! [Open a video file or an image file or a camera stream]
121121
VideoCapture cap;
@@ -132,9 +132,13 @@ int main(int argc, char** argv)
132132
cap >> originalImage;
133133
if (originalImage.empty())
134134
{
135-
cout << "Frame is empty" << endl;
136-
waitKey();
137-
break;
135+
if (parser.has("input"))
136+
{
137+
cout << "Frame is empty" << endl;
138+
break;
139+
}
140+
else
141+
continue;
138142
}
139143
int originalW = originalImage.cols;
140144
int originalH = originalImage.rows;

models/text_recognition_crnn/demo.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ std::string keys =
4141
"4: CANN + NPU}";
4242

4343

44-
class DB {
44+
class PPOCRv3DB {
4545
public:
4646

47-
DB(string modPath, Size inSize = Size(736, 736), float binThresh = 0.3,
47+
PPOCRv3DB(string modPath, Size inSize = Size(736, 736), float binThresh = 0.3,
4848
float polyThresh = 0.5, int maxCand = 200, double unRatio = 2.0,
4949
dnn::Backend bId = DNN_BACKEND_DEFAULT, dnn::Target tId = DNN_TARGET_CPU) : modelPath(modPath), inputSize(inSize), binaryThreshold(binThresh),
5050
polygonThreshold(polyThresh), maxCandidates(maxCand), unclipRatio(unRatio),
@@ -215,7 +215,7 @@ int main(int argc, char** argv)
215215
bool save = parser.get<bool>("save");
216216
bool viz = parser.get<float>("viz");
217217

218-
DB detector("../text_detection_db/text_detection_DB_IC15_resnet18_2021sep.onnx", inpSize, binThresh, polyThresh, maxCand, unRatio, backendTargetPairs[backendTargetid].first, backendTargetPairs[backendTargetid].second);
218+
PPOCRv3DB detector("../text_detection_db/text_detection_en_ppocrv3_2023may.onnx", inpSize, binThresh, polyThresh, maxCand, unRatio, backendTargetPairs[backendTargetid].first, backendTargetPairs[backendTargetid].second);
219219
CRNN recognizer(modelPath, backendTargetPairs[backendTargetid].first, backendTargetPairs[backendTargetid].second);
220220
//! [Open a video file or an image file or a camera stream]
221221
VideoCapture cap;
@@ -232,9 +232,13 @@ int main(int argc, char** argv)
232232
cap >> originalImage;
233233
if (originalImage.empty())
234234
{
235-
cout << "Frame is empty" << endl;
236-
waitKey();
237-
break;
235+
if (parser.has("input"))
236+
{
237+
cout << "Frame is empty" << endl;
238+
break;
239+
}
240+
else
241+
continue;
238242
}
239243
int originalW = originalImage.cols;
240244
int originalH = originalImage.rows;

0 commit comments

Comments
 (0)