Reputation: 810
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?
Upvotes: 0
Views: 773
Reputation: 575
I suppose your problem is connected to this issue. There is a workaround suggested in this comment. It suggests to run pyinstaller as
pyinstaller -F --add-data opencv_ffmpeg410_64.dll;. script.py
I've adapted it to your OpenCV version. Make sure this dll exists anywhere.
Upvotes: 2