0

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?

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.