We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import sys import imp from imp import reload
import time
def SpeedTest(image_path): grr = cv2.imread(image_path) model = pr.LPR("model/cascade.xml", "model/model12.h5", "model/ocr_plate_all_gru.h5") model.SimpleRecognizePlateByE2E(grr) t0 = time.time() for x in range(20): model.SimpleRecognizePlateByE2E(grr) t = (time.time() - t0)/20.0 print ("Image size :" + str(grr.shape[1])+"x"+str(grr.shape[0]) + " need " + str(round(t*1000,2))+"ms")
from PIL import ImageFont from PIL import Image from PIL import ImageDraw fontC = ImageFont.truetype("./Font/platech.ttf", 14, 0)
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) draw.text((int(rect[0] + 1), int(rect[1] - 16)), addText.encode('utf-8').decode('utf-8'), (255, 255, 255), font=fontC) imagex = np.array(img) return imagex
import HyperLPRLite as pr import cv2 import numpy as np grr = cv2.imread("images_rec/1.jpg") model = pr.LPR("model/cascade.xml","model/model12.h5","model/ocr_plate_all_gru.h5") for pstr,confidence,rect in model.SimpleRecognizePlateByE2E(grr): if confidence>0.7: image = drawRectBox(grr, rect, pstr+" "+str(round(confidence,3))) print("plate_str:") print (pstr) print ("plate_confidence") print(confidence)
cv2.imshow("image",image) cv2.waitKey(0)
SpeedTest("images_rec/2_.jpg")
The text was updated successfully, but these errors were encountered:
将demo.py修改如下: 1:注释掉以下几行
2::将def drawRectBox(image,rect,addText)函数中 代码修改如下 draw.text((int(rect[0] + 1), int(rect[1] - 16)), addText.encode('utf-8').decode('utf-8'), (255, 255, 255), font=fontC)
Sorry, something went wrong.
No branches or pull requests
import sys
import imp
from imp import reload
reload(sys)
imp.reload(sys)
sys.setdefaultencoding('utf-8')
import time
def SpeedTest(image_path):
grr = cv2.imread(image_path)
model = pr.LPR("model/cascade.xml", "model/model12.h5", "model/ocr_plate_all_gru.h5")
model.SimpleRecognizePlateByE2E(grr)
t0 = time.time()
for x in range(20):
model.SimpleRecognizePlateByE2E(grr)
t = (time.time() - t0)/20.0
print ("Image size :" + str(grr.shape[1])+"x"+str(grr.shape[0]) + " need " + str(round(t*1000,2))+"ms")
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
fontC = ImageFont.truetype("./Font/platech.ttf", 14, 0)
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)
draw.text((int(rect[0] + 1), int(rect[1] - 16)), addText.encode('utf-8').decode('utf-8'), (255, 255, 255), font=fontC)
imagex = np.array(img)
return imagex
import HyperLPRLite as pr
import cv2
import numpy as np
grr = cv2.imread("images_rec/1.jpg")
model = pr.LPR("model/cascade.xml","model/model12.h5","model/ocr_plate_all_gru.h5")
for pstr,confidence,rect in model.SimpleRecognizePlateByE2E(grr):
if confidence>0.7:
image = drawRectBox(grr, rect, pstr+" "+str(round(confidence,3)))
print("plate_str:")
print (pstr)
print ("plate_confidence")
print(confidence)
cv2.imshow("image",image)
cv2.waitKey(0)
SpeedTest("images_rec/2_.jpg")
The text was updated successfully, but these errors were encountered: