47 self.
modelname =
"text_recognition_CRNN_EN_2021sep-act_int8-wt_int8-quantized.onnx"
49 self.
tdname =
"text_detection_DB_IC15_resnet18_2021sep.onnx"
50 elif lang ==
"Chinese":
51 self.
modelname =
"text_recognition_CRNN_CN_2021nov-act_int8-wt_int8-quantized.onnx"
52 self.
charset =
"charset_3944_CN.txt"
53 self.
tdname =
"text_detection_DB_TD500_resnet18_2021sep.onnx"
55 jevois.LFATAL(
"Invalid language selected")
57 root =
"/jevoispro/share/npu/other/"
63 inputSize = [512, 288],
64 binaryThreshold = 0.3,
65 polygonThreshold = 0.5,
68 backendId = cv2.dnn.DNN_BACKEND_TIMVX,
69 targetId = cv2.dnn.DNN_TARGET_NPU)
75 self.
w, self.
h = (0, 0)
81 idle, winw, winh = helper.startFrame()
84 dx, dy, dw, dh = helper.drawInputFrame(
"c", inframe,
False,
False)
87 frame = inframe.getCvBGRp()
94 frame = cv2.resize(frame, [w, h])
97 if (w % 32) != 0
or (h % 32) != 0:
98 jevois.LFATAL(
"Input width and height must be multiples of 32")
101 if self.
w != w
or self.
h != h:
103 self.
w, self.
h = (w, h)
106 results = self.
detector.infer(frame)
108 for box, score
in zip(results[0], results[1]):
109 texts.append(self.
recognizer.infer(frame, box.reshape(8)))
112 pts = np.array(results[0]).astype(np.single)
113 helper.drawPoly(pts, 0xff0000ff,
True)
114 for box, text
in zip(results[0], texts):
115 helper.drawText(float(box[1][0]), float(box[1][1]), text, 0xff0000ff);
118 fps = self.
timer.stop()
119 helper.iinfo(inframe, fps, winw, winh);
120 helper.itext(
"JeVois-Pro - Scene text detection and decoding")
121 helper.itext(
"Detection: " + self.
tdname)
122 helper.itext(
"Charset: " + self.
charset)
123 helper.itext(
"Recognition: " + self.
modelname)