資源簡介
python車牌檢測識別代碼,個人感覺還是不錯,識別率比較高!
代碼片段和文件信息
import?numpy?as?np
import?cv2
from?hyperlpr_py3?import?pipline
#?定義旋轉rotate函數
def?rotate(image?angle?center=None?scale=1.0):
????#?獲取圖像尺寸
????(h?w)?=?image.shape[:2]
?
????#?若未指定旋轉中心,則將圖像中心設為旋轉中心
????if?center?is?None:
????????center?=?(w?/?2?h?/?2)
?
????#?執行旋轉
????M?=?cv2.getRotationMatrix2D(center?angle?scale)
????image_rotated?=?cv2.warpAffine(image?M?(w?h))
?
????#?返回旋轉后的圖像
????return?image_rotated
capture?=?cv2.VideoCapture(0)
while(True):
????#?獲取一幀
????ret?frame?=?capture.read()
????frame_rotated?=?rotate(frame?180)
????#?調用車牌識別模塊
????frame_?res??=?pipline.SimpleRecognizePlate(frame_rotated)
????
????#htitch?=?np.hstack((frame_rotated?frame_))
????#cv2.imshow(‘License?Plate?Detection?Recognition‘?htitch)
????cv2.imshow(‘License?Plate?Detection?Recognition‘?frame_)
????if?cv2.waitKey(1)?==?ord(‘q‘):
????????break
評論
共有 條評論