Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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

click to hide/show revision 2
No.2 Revision

updated 2014-09-15 15:50:08 -0600

berak gravatar image

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)]

cv2.videoCapture(1)] for i in range (0,len(cams)): read, frame = cams[i].read() cv2.imshow("Cameras",frame)

cv2.imshow("Cameras",frame)

     cv2.waitKey(1) #I added this to play with timings, thought it might
might help - didn't.

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