Ejemplo n.º 1
0
        if cv2.waitKey(1) == ord('q'):
            break

        fps.update()

    fps.stop()
    print("[INFO] elasped time: {:.2f}".format(fps.elapsed()))
    print("[INFO] approx. FPS: {:.2f}".format(fps.fps()))

    video.stop()
    cv2.destroyAllWindows()

elif args["mode"] == 1:
    video = cv2.VideoCapture(PATH_TO_VIDEO)

    while (video.isOpened()):
        ret, frame = video.read()
        frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
        frame_expanded = np.expand_dims(frame_rgb, axis=0)

        frame, classes, count = perform_detection(frame, frame_expanded)

        cv2.imshow('Object detector', frame)

        if cv2.waitKey(1) == ord('q'):
            break

    video.release()
    cv2.destroyAllWindows()

elif args["mode"] == 2: