未验证 提交 d3ae34fb 编写于 作者: C channings 提交者: GitHub

yapf fix coding style for mask_detection (#376)

* yapf style for mask_detection

* delete font file

* yapf style MaskDetection
上级 80c223bf
# -*- coding:utf-8 -*-
import paddlehub as hub import paddlehub as hub
import cv2 import cv2
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont
...@@ -12,7 +13,8 @@ module = hub.Module(name="pyramidbox_lite_mobile_mask") ...@@ -12,7 +13,8 @@ module = hub.Module(name="pyramidbox_lite_mobile_mask")
def paint_chinese(im, chinese, position, fontsize, color_bgr): def paint_chinese(im, chinese, position, fontsize, color_bgr):
img_PIL = Image.fromarray(cv2.cvtColor( img_PIL = Image.fromarray(cv2.cvtColor(
im, cv2.COLOR_BGR2RGB)) # 图像从OpenCV格式转换成PIL格式 im, cv2.COLOR_BGR2RGB)) # 图像从OpenCV格式转换成PIL格式
font = ImageFont.truetype('思源黑体SC-Heavy.otf', fontsize, encoding="utf-8") font = ImageFont.truetype(
'SourceHanSansSC-Medium.otf', fontsize, encoding="utf-8")
#color = (255,0,0) # 字体颜色 #color = (255,0,0) # 字体颜色
#position = (100,100)# 文字输出位置 #position = (100,100)# 文字输出位置
color = color_bgr[::-1] color = color_bgr[::-1]
...@@ -38,8 +40,8 @@ maskIndex = 0 ...@@ -38,8 +40,8 @@ maskIndex = 0
index = 0 index = 0
data = [] data = []
# capture = cv2.VideoCapture(0) # 打开摄像头 capture = cv2.VideoCapture(0) # 打开摄像头
capture = cv2.VideoCapture('./2.mp4') # 打开视频文件 #capture = cv2.VideoCapture('./2.mp4') # 打开视频文件
while (1): while (1):
frameData = {} frameData = {}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册