DEV Community

Raunak Tamang
Raunak Tamang

Posted on

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('') 
                                          #ipwebcam address 

    while True:                    #while true, read the camera
        ret , frame =
        re1 , frame1 =
        ret2 , frame2 =

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

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


you can check out this in GitHub too

Discussion (0)