Display ip camera

Hello Streamlit Community,

I hope this message finds you well. I am currently working on a Streamlit app that involves displaying a live camera feed using OpenCV. The following code is functional, but I am experiencing a delay of around 6 to 8 seconds:

def display_camera():
    cap = cv2.VideoCapture(ip_url)
    cap.set(3, 640)
    cap.set(4, 150)

    FRAME_WINDOW = st.image([])
    while True:
        success, img = cap.read()
        frame = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
        FRAME_WINDOW.image(frame, width=640)

I am seeking advice on how to optimize this code for a quicker display. Any suggestions or alternative approaches would be greatly appreciated.

Thank you in advance for your help!

Hi @Vivek_Tiwari . But here is the small suggestion that to use streamlit webrtc module for working in the cloud. Cv2.videocapture doesn’t works in cloud.