Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Why do I get an interaction between

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

Why do I get an interaction betweenbetween different cameras?

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

Why do I get an interaction between different cameras?

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) cv2.imshow('Left',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

Why do I get an interaction between different cameras?

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('Left',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

Quirk also is that the following works:

cv2.imshow('Left',frame1)  # code line works
cv2.imshow('Right',frame1)  # code line hangs

While the following does not work:

cv2.imshow('Left',frame2)  # code line works
cv2.imshow('Right',frame2)  # code line hangs

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

Why do I get an interaction between different cameras?

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('Left',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

Quirk also is that the following works:

cv2.imshow('Left',frame1)  # code line works
cv2.imshow('Right',frame1)  # code line hangs
still works (but using same buffer)

While the following does not work:

cv2.imshow('Left',frame2)  # code line works
not longer works (using second buffer)
cv2.imshow('Right',frame2)  # code line hangs
ditto

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

Another couple of things. Coding up to using only one camera and changing the index for the camera, to select either one or the other camera, works.

I found, by experimenting, that releasing camera 1 allow camera 2 to read a buffer BUT alternatingly creating/then releasing cameras did not work - there didn't seem to be an alternate way to do this with the python.

So, it appears, that something more fiddly than creating cam1 and cam2 is required as the cameras seem to share something that does not allow them to be active at same time.

Cheers, B

Why do I get an interaction between different cameras?

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('Left',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

Quirk also is that the following works:

cv2.imshow('Left',frame1)  # code line works
cv2.imshow('Right',frame1)  # code line still works (but using same buffer)

While the following does not work:

cv2.imshow('Left',frame2)  # code line not longer works (using second buffer)
cv2.imshow('Right',frame2)  # ditto

I am using a stereo camera which works as two separate cameras. Camera works with other software. Runnding Running OpenCV3.2 on 64bit Python 2.7.9 (stackless).

Another couple of things. Coding up to using only one camera and changing the index for the camera, to select either one or the other camera, works.

I found, by experimenting, that releasing camera 1 allow camera 2 to read a buffer BUT alternatingly creating/then releasing cameras did not work - there didn't seem to be an alternate way to do this with the python.

So, it appears, that something more fiddly than creating cam1 and cam2 is required as the cameras seem to share something that does not allow them to be active at same time.

Cheers, B

Why do I get an interaction between different cameras?

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('Left',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

Quirk also is that the following works:works unless I swap the order of the VideoCapture(x):

cv2.imshow('Left',frame1)  # code line works
cv2.imshow('Right',frame1)  # code line still works (but using same buffer)

While the following does not work:work unless I swap the order of the VideoCapture(x):

cv2.imshow('Left',frame2)  # code line not longer works (using second buffer)
cv2.imshow('Right',frame2)  # ditto

I am using a stereo camera which works as two separate cameras. Camera works with other software. Running OpenCV3.2 on 64bit Python 2.7.9 (stackless).

Another couple of things. Coding up to using only one camera and changing the index for the camera, to select either one or the other camera, works.

I found, by experimenting, that releasing camera 1 allow camera 2 to read a buffer BUT alternatingly creating/then releasing cameras did not work - there didn't seem to be an alternate way to do this with the python.

So, it appears, that something more fiddly than creating cam1 and cam2 is required as the cameras seem to share something that does not allow them to be active at same time.

Cheers, B

Why do I get an interaction between different cameras?

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('Left',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

Quirk also is that the following works unless I swap the order of the VideoCapture(x):

cv2.imshow('Left',frame1)  # code line works
cv2.imshow('Right',frame1)  # code line still works (but using same buffer)

While the following does not work unless I swap the order of the VideoCapture(x):

cv2.imshow('Left',frame2)  # code line not longer works (using second buffer)
cv2.imshow('Right',frame2)  # ditto

I am using a stereo camera which works as two separate cameras. Camera works with other software. Running OpenCV3.2 on 64bit Python 2.7.9 (stackless).

Another couple of things. Coding up to using only one camera and changing the index for the camera, to select either one or the other camera, works.

I found, by experimenting, that releasing camera 1 allow camera 2 to read a buffer BUT alternatingly creating/then releasing cameras did not work - there didn't seem to be an alternate way to do this with the python.

So, it appears, that something more fiddly than creating cam1 and cam2 is required as the cameras seem to share something that does not allow them to be active at same time.

time.
Cheers, B