# and start the FPS counter print("[INFO] sampling frames from WebcamVideoStream module...") vs = WebcamVideoStream(src=0).start() time.sleep(2.0) fps = FPS().start() # loop over some frames...this time using the threaded stream while True: # grab the frame from the threaded video stream and resize it # to have a maximum width of 400 pixels frame = vs.read() frame = imutils.resize(frame, width=400) # update the FPS counter fps.update() fps._end = datetime.datetime.now() # print(fps.fps()) cv2.putText(frame, str(fps.fps()), (50, 200), cv2.FONT_HERSHEY_SIMPLEX, 3, (0, 0, 255), 10) cv2.imshow("Frame", frame) key = cv2.waitKey(1) & 0xFF if key == ord("q"): break except KeyboardInterrupt: # stop the timer and display FPS information fps.stop() print("[INFO] elasped time: {:.2f}".format(fps.elapsed())) print("[INFO] approx. FPS: {:.2f}".format(fps.fps()))