diff --git a/README.md b/README.md index ccacd1e..c8485c0 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,16 @@ import numpy as np grr = cv2.imread("images_rec/demo1.jpg") model = pr.LPR("model/cascade.xml","model/model12.h5","model/ocr_plate_all_gru.h5") +def drawRectBox(image,rect,addText): + cv2.rectangle(image, (int(rect[0]), int(rect[1])), (int(rect[0] + rect[2]), int(rect[1] + rect[3])), (0,0, 255), 2,cv2.LINE_AA) + cv2.rectangle(image, (int(rect[0]-1), int(rect[1])-16), (int(rect[0] + 115), int(rect[1])), (0, 0, 255), -1, + cv2.LINE_AA) + img = Image.fromarray(image) + draw = ImageDraw.Draw(img) + draw.text((int(rect[0]+1), int(rect[1]-16)), addText.decode("utf-8"), (255, 255, 255), font=fontC) + imagex = np.array(img) + return imagex + for pstr,confidence,rect in model.SimpleRecognizePlateByE2E(grr): if confidence>0.7: image = drawRectBox(grr, rect, pstr+" "+str(round(confidence,3)))