close
看完了上一篇,其實大家應該比較有感覺了,沒錯,這跟我們停車場的車牌辨識,是不是很像? 所以,我們就來進階一點,將這玩意寫出來吧,其實也沒幾行code :)
import time
import pytesseract
def main():
pytesseract.pytesseract.tesseract_cmd=r'C:\Program Files\Tesseract-OCR\tesseract.exe'
carDict={}
myPath='D:\\!Work\\!X\\SampleTrace\\venv\\src\\'
while True:
carPlate=input("Please enter : ")
if carPlate == 'Q' or carPlate =='q':
break
carPlate = myPath + carPlate
keyText = pytesseract.image_to_string(Image.open(carPlate))
if keyText in carDict:
exitTime = time.asctime()
print("車輛出場時間: ",keyText,":" ,exitTime)
del carDict[keyText]
else:
entryTime=time.asctime()
print("車輛入場時間: ",keyText,":",entryTime)
carDict[keyText]=entryTime
print(carDict)
if (__name__ == '__main__'):
main()
接下來,我們就是拿這個時間來算錢! 出場-離場 = 幾分鐘 blablabla去算~即可!
全站熱搜
留言列表