def main(): vc = WebcamVideoStream(src=0).start() reader = easyocr.Reader(['en']) while True: # read the current camera frame frame = vc.read() # show the current frame (untouched) cv2.imshow("My webcam", frame) # if 'x' key is pressed, exit the loop if cv2.waitKey(1) & 0XFF == ord('x'): break # if 'c' key is pressed, process the frame for OCR if cv2.waitKey(1) & 0xFF == ord('c'): # copy the image so it will be a cleaned image for tesseract img = vc.mask_frame() # DEBUG img_box = draw_boxes(img, reader) # draw the chart containing the image with boxes cv2.imshow("Tesseract", img_box) print_img_str(img, reader) # close the window and de-allocate any associated memory usage cv2.destroyAllWindows() # close the already opened camera vc.stop()