DEV Community

Raunak Tamang
Raunak Tamang

Posted on

3

stream multiple camera using OpenCV

hey folks, recently I am working on a project which needs hand-on experience on OpenCV. As I am a newbie in the OpenCV framework I tried to use the basic kinds of stuff out of it, so I started to work with reading the camera and stream it. just simple and easy kind of stuff.


import numpy as np
    import cv2


    #capture the webcam
    vid1 = cv2.VideoCapture(0)
    vid2 = cv2.VideoCapture(1)
    vid3 = cv2.VideoCapture('http://192.168.2.2:5000/video') 
                                          #ipwebcam address 


    while True:                    #while true, read the camera
        ret , frame = vid1.read()
        re1 , frame1 = vid2.read()
        ret2 , frame2 = vid3.read()

        if (ret):
            cv2.imshow('cam0',frame)    #frame with name and 
                                        variable of the camera 
            cv2.imshow('cam1', frame1)
            cv2.imshow('cam3',frame2)

        if cv2.waitKey(1) & 0xFF == ord('q'):      #to break the 
                                    loop and terminate the program 
            break

    vid1.release()
    vid2.release()
    vid3.release()


you can check out this in GitHub too
https://github.com/cyber-hoax/camera_stream_openCV
Enter fullscreen mode Exit fullscreen mode

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay