示例#1
0
 def show_frame(self):
     frame = cv2.flip(self._engine.canvas, 1)
     cv2image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGBA)
     img = Image.fromarray(cv2image)
     imgtk = ImageTk.PhotoImage(image=img)
     self._lmain.imgtk = imgtk
     self._lmain.configure(image=imgtk)
     self._lmain.after(10, self.show_frame)
示例#2
0
 def cv2ImgAddText(self,
                   img,
                   text,
                   left,
                   top,
                   textColor=(0, 255, 0),
                   textSize=20):
     if (isinstance(img, numpy.ndarray)):  # 判断是否OpenCV图片类型
         img = Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
     # 创建一个可以在给定图像上绘图的对象
     draw = ImageDraw.Draw(img)
     # 字体的格式
     fontStyle = ImageFont.truetype("font/simsun.ttc",
                                    textSize,
                                    encoding="utf-8")
     # 绘制文本
     draw.text((left, top), text, textColor, font=fontStyle)
     # 转换回OpenCV格式
     return cv2.cvtColor(numpy.asarray(img), cv2.COLOR_RGB2BGR)