cv2.imshow() to show sequence of live images
Hi, I am trying out a program in python using OpenCV to see feeds from multiple webcams.
I have no trouble viewing the individual webcam feeds in separate windows and no problem viewing or recording feeds from individual cameras.
I am playing around with an idea that I have to use 2 cameras and show each one in every-other frame - sort of the way 3-d video works in some instances.
I am attempting to show the cameras by using a for loop, but it is not working.
cams = [cv2.videoCapture(0),
cv2.videoCapture(1)]
for i in range (0,len(cams)):
read, frame = cams[i].read()
cv2.imshow("Cameras",frame)
cv2.waitKey(1) #I added this to play with timings, thought it might help - didn't.
In theory, it should be simply playing frames from source 1 and then source 2 and repeat.. but what seems to actually happen is it reads each camera once and then just sequences the images... repeatedly - the "feed" that is being displayed is not live after the first frame.
Would anyone know why this is happening?
Thank you, J
Hi berak, thank you...
Thing is, I don't want the images to appear in 2 different windows... Doing that, BTW,works just fine...
What I'm attempting is to make a single window where every other frame is Cam1 and the others are Cam 2...
Single window: cam1, cam2, cam1, cam2, cam1, cam2, etc.
What is actually happening is that the window is showing every other frame from cams one and two respectively as I hoped, but it is only capturing frame from each camera once, and then repeatedly showing the same frame(s) over and over...
So, I want: Cam1(frame1), Cam2(frame1), Cam1(frame2),Cam2(frame2),Cam1(frame3), Cam2(frame3), etc.
What I'm getting: Cam1(frame1), Cam2(frame1),Cam1(frame1), Cam2(frame1),Cam1(frame1), Cam2(frame1), etc.
Puzzling.