ValueError:zerosize数组到没有标识的缩减操作最大值

2024-09-30 19:28:05 发布

您现在位置:Python中文网/ 问答频道 /正文

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

/usr/lib/python2.7/dist-packages/picamera/encoders.py:544: 
PiCameraResolutionRounded: frame size rounded up from 3280x2464 to 3296x2464
width, height, fwidth, fheight)))

Traceback (most recent call last):
File "tc-setupjob.py", line 253, in mouse_handler
pf.findFirstFromCoords(img,(x,y),20)
File "/home/pi/rpiTelecine/rpiTelecine/perforation.py", line 230, in 
findFirstFromCoords
threshVal = int(vROI.max()*self.thresholdVal)
File "/usr/lib/python2.7/dist-packages/numpy/core/_methods.py", line 17, in 
_amax
out=out, keepdims=keepdims)
ValueError: zero-size array to reduction operation maximum which has no 
identity

这应该是一个脚本,它可以检测出胶片上的穿孔,并在您单击它生成的预览图像区域时确定裁剪区域。在

这些脚本来自github,位于:

https://github.com/Alexamder/rpitelecine/blob/master/tc-setupjob.py

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

https://github.com/Alexamder/rpitelecine/blob/master/rpiTelecine/perforation.py

我遇到了一个建议,即捕获异常并忽略它,该建议来自于在另一个应用程序中遇到类似错误的人,我想我可以添加一个异常:

^{pr2}$

默认情况下,代码如下所示:

  #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

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


Tags: infrompyselfhomelinepiwin