(-215:断言失败)数字<函数'cv :: icvExtractPattern'中的max_number错误? [英] (-215:Assertion failed) number < max_number in function 'cv::icvExtractPattern' error?
问题描述
我正在尝试将这个python脚本作为exe文件运行-使用pyinstaller,这会引发此错误:
I'm trying to run this python script as an exe file - using pyinstaller, and it raise me this error:
[ERROR:0]全局C:\ projects \ opencv-python \ opencv \ modules \ videoio \ src \ cap.cpp(415)cv :: VideoWriter :: open VIDEOIO(CV_IMAGES):引发了OpenCV异常:OpenCV(4.2.0)C:\ projects \ opencv-python \ opencv \ modules \ videoio \ src \ cap_images.cpp:267:错误:(-215:断言失败)数字<函数'cv :: icvExtractPattern'中的max_number
[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'
当我将其作为python脚本运行时,它运行良好.python脚本:
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)
我在命令行中使用pyinstaller:
I'm using pyinstaller in the command line:
pyinstaller --onefile python_script.py
我应该进行哪些更改才能使其正常工作?
what should I change to make it work?
推荐答案
主要解决方案:可能是 DLL
错误.
我想您的问题与此问题有关.在此评论中,建议了一种解决方法.建议将pyinstaller运行为
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;.python_script.py
请确保适应您的OpenCV版本.确保此dll位于任何地方.
Make sure to adapt to your OpenCV version. Make sure this dll exists anywhere.
替代:我相信错误
python \ opencv \ modules \ videoio \ src \ cap_images.cpp:267:错误:(-215:断言失败)编号<函数'cv :: icvExtractPattern'中的max_number
python\opencv\modules\videoio\src\cap_images.cpp:267: error: (-215:Assertion failed) number < max_number in function 'cv::icvExtractPattern'
是由此行引起的,此处 fourcc = cv2.VideoWriter_fourcc(*"XVID")
,其中设置的值为>
最大值.
is caused by this line here fourcc = cv2.VideoWriter_fourcc(*"XVID")
where the value that is set is >
the max value.
您可以尝试将fourcc设置为 -1
.然后,它将为您提供用于编写的视频编解码器的选择.我已经看到未压缩的视频选择适用于大多数平台.
You can try to set the fourcc to -1
. Then, it will give you a choice of video codecs to use for writing. I have seen that uncompressed video choice works fine for most of the platforms.
这篇关于(-215:断言失败)数字<函数'cv :: icvExtractPattern'中的max_number错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!