import requests
import cv2
from time import sleep
from mpython_conn import controller
import os
from functions import *
# m = controller()
# m.set_servo(9, 180)
# 打开摄像头
cap = cv2.VideoCapture(0)

def main():
    door_status = 1
    work = 0

###学生从这里开始编程
    ret, frame = cap.read()
    cv2.imshow("r", frame)

    if ord('s') == cv2.waitKey(1):
        file_path = os.path.join(os.path.expanduser("~"), "Desktop", "car.png")
        cv2.imwrite(file_path, frame)
        print("success to save"+"car.jpg")
        
        plate_number = get_license_plate_number(file_path)
        print("识别到的车牌号码为: " + plate_number)
###学生到这里编程结束    
        

while True:
    main()
    k = cv2.waitKey(1) & 0xFF#按键判断
    if ord(' ') == cv2.waitKey(10):
        break
cv2.destroyAllWindows()
cap.release()
