Code is:
import numpy as np
import cv2
cam1 = cv2.VideoCapture(1)
cam2 = cv2.VideoCapture(2)
cv2.namedWindow( "Left", cv2.WINDOW_AUTOSIZE );
cv2.namedWindow( "Right", cv2.WINDOW_AUTOSIZE );
while(True):
# Capture frame-by-frame
ret, frame1 = cam1.read()
ret, frame2 = cam2.read()
# Display the resulting frame
cv2.imshow('Right',frame1) # code line works
cv2.imshow('Right',frame2) # code line hangs
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cam1.release()
cam2.release()
cv2.destroyAllWindows()
Problem is that code hangs on imshow of frame 2 if and only if frame1 was read. That is, if I delete the code line that hangs then code runs. If I delete code line that hangs but change frame used to frame2 then code runs. So, when both camx.read() are called it seems fine, it is only hanging when the two imshow are being called.
Error reported is:
Traceback (most recent call last):
File "D:\python\webcam.py", line 19, in <module>
cv2.imshow('Right',frame2) # hangs
error: C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\highgui\src\window.cpp:304: error: (-215) size.width>0 && size.height>0 in function cv::imshow
I am using a stereo camera which works as two separate cameras. Camera works with other software. Runnding OpenCV3.2 on 64bit Python 2.7.9 (stackless).
Cheers, B