I'm trying to build a simple code to test my cameras. In my code, I use these lines for webcam;
cam = cv2.VideoCapture(0)
cv2.namedWindow("test")
ret, frame = cam.read()
cv2.imshow("test", frame)
and for IP camera
myip='http://admin:[email protected]:XXXX/stream/video/mjpeg'
cam = cv2.VideoCapture(str(myip))
cv2.namedWindow("test")
ret, frame = cam.read()
cv2.imshow("test", frame)
In PyCharm, when I run both codes, my cameras works perfectly. Also if I enter myip url in browser, ip camera shows perfectly.
But, when I build an exe file with PyInstaller , only the first code (webcam code) works. The second code shows this error;
cv2.error: OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:352: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'
Where is my fault? Can you fix it please?