def start(self): # Do not change width = 352 height = 352 # output to capture image output = np.empty((height, width, 3), dtype=np.uint8) # Init camera camera = Camera(width, height) # Init image saver imageSaver = ImageSaver() # Init model model = self.getModel() # Init notificator notificator = Notificator() # Start predicting tempCount = 1 while True: #print("Step...") #start = time.time() # Capture image to output camera.capture(output) imageToCrop = Image.fromarray(output) image = self.cropImage(imageToCrop, 110, 87, 224) tempName = 'temp{}.jpg'.format(tempCount) image.save(tempName) tempCount += 1 if tempCount > Notificator.PREDICTIONS_LENGTH: tempCount = 1 # Predict prediction = model.predict(imagePath=tempName) # Save image to disk with label and probability imageSaver.save(image, prediction) # Manage Notification notificator.manageNotification(prediction) #print("Step took {} seconds".format(time.time()-start)) camera.close()
#start logger.info("Starting program") #red led logger.info("Turning red led on") led.turnLedOn("red") #start capturing condition = True logger.info("Reading distance") try: while condition: distance = sonic.getDistance() logger.debug("Reading distance => {dist}".format(dist=distance)) time.sleep(1) if distance >= 30 and distance <= 120: camera.captureImage() camera.recognizePlate() except KeyboardInterrupt: logger.info("Stopping reading distance") #close logger.info("Releasing resources camera") camera.close() #end logger.info("Closing program") led.turnLedOff("red") led.turnLedOff("green")