本文介绍了(-215:断言失败)数字<函数'cv :: icvExtractPattern'中的max_number错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将这个python脚本作为exe文件运行-使用pyinstaller,这会引发此错误:

I'm trying to run this python script as an exe file - using pyinstaller, and it raise me this error:

当我将其作为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.

替代:我相信错误

是由此行引起的,此处 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错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 11:23