I'm trying to run this python script as an exe file - using pyinstaller, and it raise me this error:
[ERROR:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap.cpp (415) cv::VideoWriter::open VIDEOIO(CV_IMAGES): raised OpenCV exception: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\videoio\src\cap_images.cpp:267: error: (-215:Assertion failed) number < max_number in function 'cv::icvExtractPattern'
When I'm running it as a python script, it works well. the python script:
SCREEN_SIZE = (1920, 1080)
FPS = 20.0
fourcc = cv2.VideoWriter_fourcc(*"XVID")
out = cv2.VideoWriter("output.avi", fourcc, FPS, SCREEN_SIZE)
I'm using pyinstaller in the command line:
pyinstaller --onefile python_script.py
what should I change to make it work?
This is absolutely crazy, but similar problem was fixed to me by renaming output file. If output filename includes too many digits then this goddamn number validation in cap_images will fail even if I use cv2.VideoWriter
https://github.com/opencv/opencv/blob/4.x/modules/videoio/src/cap_images.cpp
while (pos < len && isdigit(filename[pos]))
{
char ch = filename[pos];
number = (number * 10) + (uint64_t)((int)ch - (int)'0');
CV_Assert(number < max_number);
number_str_size++;
CV_Assert(number_str_size <= 64); // don't allow huge zero prefixes
pos++;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With