I’m building an app to benchmark a process running on a webcam video-feed. Every refresh means I have to re-initialize the camera.(Depending on the camera can take up to 2-3 seconds of waiting). I make many changes fast, and was hoping to cut the 2-3 seconds for each refresh by caching the video capture.
Here is how I’m trying to implement caching.
import cv2 @st.cache() def load_camera() -> cv2.VideoCapture: CAMERA_FLAG = 0 camera = cv2.VideoCapture(CAMERA_FLAG) return camera camera = load_camera()
Here is the error that I get
Has anyone successfully been able to st.cache a cv2 video capture, or found a different way to take frames from a webcam?