Python ValueError:从零大小数组到没有标识的最大缩减操作

Python ValueError:从零大小数组到没有标识的最大缩减操作,python,Python,我正在使用Github的一些脚本进行一个电视电影项目,并遇到以下错误(包括回溯:) 这应该是一个脚本,它可以检测一条胶片上的穿孔,并在预览中单击图像区域时获取该穿孔并确定裁剪区域 有问题的脚本来自github,位于此处: 这就需要这个,这似乎是问题所在: 有人在不同的应用程序中遇到类似的错误,我提出了捕获异常并忽略它的建议,我认为我可以添加一个异常: #take a vertical section of pixels from the ROI and threshold it try

我正在使用Github的一些脚本进行一个电视电影项目,并遇到以下错误(包括回溯:)

这应该是一个脚本,它可以检测一条胶片上的穿孔,并在预览中单击图像区域时获取该穿孔并确定裁剪区域

有问题的脚本来自github,位于此处:

这就需要这个,这似乎是问题所在:

有人在不同的应用程序中遇到类似的错误,我提出了捕获异常并忽略它的建议,我认为我可以添加一个异常:

   #take a vertical section of pixels from the ROI and threshold it
try:
    vROI = self.ROIimg[:,xStart-win:xStart+win]
    threshVal = int(vROI.max()*self.thresholdVal)
except ValueError:
    pass
默认情况下,代码如下所示:

  #take a vertical section of pixels from the ROI and threshold it
        vROI = self.ROIimg[:,xStart-win:xStart+win]
        threshVal = int(vROI.max()*self.thresholdVal)
如果添加异常,则会出现以下错误:

pi@raspberrypi:~/rpiTelecine $ sudo python tc-setupjob.py -s8 fats
Traceback (most recent call last):
  File "tc-setupjob.py", line 44, in <module>
    from tc_common import *
  File "/home/pi/rpiTelecine/tc_common.py", line 39, in <module>
    import rpiTelecine
  File "/home/pi/rpiTelecine/rpiTelecine/__init__.py", line 44, in <module>
    from rpiTelecine.perforation import (
  File "/home/pi/rpiTelecine/rpiTelecine/perforation.py", line 54, in <module>
    class telecinePerforation():
  File "/home/pi/rpiTelecine/rpiTelecine/perforation.py", line 230, in telecinePerforation
    vROI = self.ROIimg[:,xStart-win:xStart+win]
NameError: name 'self' is not defined
pi@raspberrypi:~/rpiTelecine$sudo python tc-setupjob.py-s8 fats
回溯(最近一次呼叫最后一次):
文件“tc setupjob.py”,第44行,在
从tc_通用导入*
文件“/home/pi/rpiTelecine/tc_common.py”,第39行,在
进口紫杉醇
文件“/home/pi/rpiTelecine/rpiTelecine/_init_uuu.py”,第44行,在
从rpiTelecine.com导入(
文件“/home/pi/rpiTelecine/rpiTelecine/personation.py”,第54行,在
类telecinepersonation():
文件“/home/pi/rpiTelecine/rpiTelecine/personation.py”,第230行,电视电影穿孔
vROI=self.roimg[:,xStart-win:xStart+win]
NameError:未定义名称“self”

我刚接触Python,所以目前我正在黑暗中拍摄,如果有人能为我指出正确的方向,我将不胜感激。

请参阅这篇关于创建一个最小、完整且可验证的示例的文章:无论如何,应该有一个冒号(
)在
ValueError
之后。抱歉,我截断了冒号,它实际上就在那里。感谢您的回复,我将努力修改我的帖子。您需要将引发错误的代码包装成一个块。您可能没有添加try语句。在添加
的地方发布代码,除了
,其他人可能会提供帮助。您好谢谢你的回复,我没有try语句,但是现在我得到了一个不同的错误,我将把它和代码块一起发布。请看这篇关于创建一个最小的、完整的、可验证的示例的文章:无论如何,应该有一个冒号(
)在
ValueError
之后。抱歉,我截断了冒号,它实际上就在那里。感谢您的回复,我将努力修改我的帖子。您需要将引发错误的代码包装成一个块。您可能没有添加try语句。在添加
的地方发布代码,除了
,其他人可能会提供帮助。您好谢谢你的回复,我没有在那里的try语句,但是现在我得到了一个不同的错误,我会把它和代码块一起发布。
pi@raspberrypi:~/rpiTelecine $ sudo python tc-setupjob.py -s8 fats
Traceback (most recent call last):
  File "tc-setupjob.py", line 44, in <module>
    from tc_common import *
  File "/home/pi/rpiTelecine/tc_common.py", line 39, in <module>
    import rpiTelecine
  File "/home/pi/rpiTelecine/rpiTelecine/__init__.py", line 44, in <module>
    from rpiTelecine.perforation import (
  File "/home/pi/rpiTelecine/rpiTelecine/perforation.py", line 54, in <module>
    class telecinePerforation():
  File "/home/pi/rpiTelecine/rpiTelecine/perforation.py", line 230, in telecinePerforation
    vROI = self.ROIimg[:,xStart-win:xStart+win]
NameError: name 'self' is not defined