Skip to content

Commit 08f31a0

Browse files
committed
* 优化draw ocr 方法
1 parent 30af367 commit 08f31a0

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## OpencvToolsV1.2.0
1+
## OpencvToolsV1.2.1
22
Opencv相关操作
33

44
### 打包为wheel文件
@@ -15,6 +15,7 @@ python setup.py sdist bdist_wheel
1515
> wheel-dir 为wheel 输出文件夹,后面接项目文件夹(即包含setup.py的文件夹)
1616
1717
### 更新日志
18+
* 优化draw ocr 方法
1819
* 输出相机解码失败原因,输出解码失败详细原因
1920
* 自动安装jade最新版本
2021
* 支持华为Ascend解码

opencv_tools/jade_visualize.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def visualize(image_file,
295295
font_size=font_size)
296296
im = np.array(im)
297297

298-
return cv2.cvtColor(im,cv2.COLOR_BGR2RGB)
298+
return im
299299

300300

301301
def resize_img(img, input_size=600):
@@ -444,6 +444,7 @@ def draw_text_list(img,font_path, label_list, pt_list=[], color_list=[], font_si
444444
cv2img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # cv2和PIL中颜色的hex码的储存顺序不同
445445
pilimg = Image.fromarray(cv2img)
446446
# PIL图片上打印汉字
447+
font_path = get_font_path(font_path)
447448
draw = ImageDraw.Draw(pilimg) # 图片上打印
448449
for (label, pt, color, font_size) in zip(label_list, pt_list, color_list, font_size_list):
449450
font = ImageFont.truetype(font_path, font_size, encoding="utf-8") # 参数1:字体文件路径,参数2:字体大小
@@ -504,7 +505,7 @@ def draw_text_det_res(img, dt_boxes, txts=None,font_path=None):
504505
for idx, (box, txt) in enumerate(zip(dt_boxes, txts)):
505506
box = np.array(box).astype(np.int32).reshape(-1, 2)
506507
if txt:
507-
src_im = draw_text_list(src_im,[txt[0]], [(box[0, 0], box[3, 1])], [(0, 0, 255)], font_size_list=[54],font_path=font_path)
508+
src_im = draw_text_list(src_im, font_path, [txt], pt_list = [(box[0, 0], box[3, 1])], color_list = [(0, 0, 255)], font_size_list = [54])
508509
cv2.polylines(src_im, [box], True, color=(0, 0, 255), thickness=2)
509510
return src_im
510511

@@ -657,7 +658,7 @@ def CVShowBoxes(image,boxes,label_texts,scores,label_ids=None,num_classes=90,wai
657658
return image2
658659

659660
# OCR识别结果
660-
def draw_ocr(image, boxes, txts, scores, draw_txt=True, drop_score=0.5):
661+
def draw_ocr(image, boxes, txts, scores=None, draw_txt=True, drop_score=0.5):
661662
"""
662663
Visualize the results of OCR detection and recognition
663664
args:

opencv_tools/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# @Email : jadehh@1ive.com
77
# @Software : Samples
88
# @Desc :
9-
version = "1.2.0"
9+
version = "1.2.1"

0 commit comments

Comments
 (0)