Skip to content

Commit 107f233

Browse files
authored
Merge pull request opencv#19484 from UnaNancyOwen:fix_highlevelapi
* [dnn] fix high level api for python * [dnn] add test_textdetection_model_db * [dnn] fix textdetection test only check type and shape
1 parent 0677f3e commit 107f233

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

modules/dnn/include/opencv2/dnn/dnn.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ CV__DNN_INLINE_NS_BEGIN
12161216
* KeypointsModel creates net from file with trained weights and config,
12171217
* sets preprocessing input, runs forward pass and returns the x and y coordinates of each detected keypoint
12181218
*/
1219-
class CV_EXPORTS_W KeypointsModel: public Model
1219+
class CV_EXPORTS_W_SIMPLE KeypointsModel: public Model
12201220
{
12211221
public:
12221222
/**
@@ -1248,7 +1248,7 @@ CV__DNN_INLINE_NS_BEGIN
12481248
* SegmentationModel creates net from file with trained weights and config,
12491249
* sets preprocessing input, runs forward pass and returns the class prediction for each pixel.
12501250
*/
1251-
class CV_EXPORTS_W SegmentationModel: public Model
1251+
class CV_EXPORTS_W_SIMPLE SegmentationModel: public Model
12521252
{
12531253
public:
12541254
/**
@@ -1406,7 +1406,7 @@ class CV_EXPORTS_W_SIMPLE TextRecognitionModel : public Model
14061406

14071407
/** @brief Base class for text detection networks
14081408
*/
1409-
class CV_EXPORTS_W TextDetectionModel : public Model
1409+
class CV_EXPORTS_W_SIMPLE TextDetectionModel : public Model
14101410
{
14111411
protected:
14121412
CV_DEPRECATED_EXTERNAL // avoid using in C++ code, will be moved to "protected" (need to fix bindings first)

modules/dnn/misc/python/test/test_dnn.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,25 @@ def test_classification_model(self):
197197
normAssert(self, out, ref)
198198

199199

200+
def test_textdetection_model(self):
201+
img_path = self.find_dnn_file("dnn/text_det_test1.png")
202+
weights = self.find_dnn_file("dnn/onnx/models/DB_TD500_resnet50.onnx", required=False)
203+
if weights is None:
204+
raise unittest.SkipTest("Missing DNN test files (onnx/models/DB_TD500_resnet50.onnx). Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter.")
205+
206+
frame = cv.imread(img_path)
207+
scale = 1.0 / 255.0
208+
size = (736, 736)
209+
mean = (122.67891434, 116.66876762, 104.00698793)
210+
211+
model = cv.dnn_TextDetectionModel_DB(weights)
212+
model.setInputParams(scale, size, mean)
213+
out, _ = model.detect(frame)
214+
215+
self.assertTrue(type(out) == list)
216+
self.assertTrue(np.array(out).shape == (2, 4, 2))
217+
218+
200219
def test_face_detection(self):
201220
proto = self.find_dnn_file('dnn/opencv_face_detector.prototxt')
202221
model = self.find_dnn_file('dnn/opencv_face_detector.caffemodel', required=False)

0 commit comments

Comments
 (0)