from PIL import Image, ImageDraw, ImageFont
def draw_string(self,frame,text,x,y,fontcolor=(255,255,255),fontsize=26,):
if isinstance(frame, np.ndarray):
frame = Image.fromarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
draw = ImageDraw.Draw(frame)
fontStyle = ImageFont.truetype( self.fontpath, fontsize, encoding="utf-8")
draw.text((x,y), text, fontcolor, font=fontStyle)
return cv2.cvtColor(np.asarray(frame), cv2.COLOR_RGB2BGR)