DataBall 助力快速掌握数据集的信息和使用方式。
贵在坚持!
-----------------------------------
安装 cnocr:
pip install cnocr
cnocr识别脚本如下:
import cv2
from cnocr import CnOcr
import numpy as np
if __name__ == "__main__":
img_path = './123.jpg'
img = cv2.imread(img_path)
ocr = CnOcr(rec_root = "./ckpt")
result = ocr.ocr(cv2.cvtColor(img, cv2.COLOR_RGB2BGR))
# print("result:\n {}".format(result))
for msg in result:
xyxy = np.array(msg['position'])
x1, y1, x2, y2 = min(xyxy[:, 0]), min(xyxy[:, 1]), max(xyxy[:, 0]), max(xyxy[:, 1])
x1, y1, x2, y2 = int(x1), int(y1), int(x2), int(y2)
cv2.rectangle(img, (x1, y1), (x2, y2), (255, 255, 0), 2)
text_ = msg["text"]
score_ = msg['score']
print("---->>>> text:{} , position: {} , score: {}".format(msg["text"], (x1, y1, x2, y2),msg['score']))
cv2.namedWindow("image",0)
cv2.imshow("image",img)
cv2.waitKey(0)
log如下:
---->>>> text:贺喜· , position: (223, 69, 334, 130) , score: 0.45419251918792725
---->>>> text:福 , position: (383, 72, 424, 115) , score: 0.9946895837783813
---->>>> text:金蛇 , position: (132, 69, 240, 129) , score: 0.8557843565940857
---->>>> text:新年快乐 , position: (172, 131, 281, 170) , score: 0.8078193664550781
---->>>> text:GHAPPY CHINESE NEW YEARD , position: (160, 169, 291, 184) , score: 0.22548381984233856
---->>>> text:福 , position: (384, 178, 424, 221) , score: 0.9981645941734314
检测效果如图:
助力快速掌握数据集的信息和使用方式。
数据可以如此美好!