DEV Community

Raunak Tamang
Raunak Tamang

Posted on

2

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

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post →

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay