ValueError:零大小数组到减少操作最大值,没有标识

时间:2017-04-08 20:06:34

标签: python

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

/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

我遇到了一个捕获异常的建议,并忽略了遇到类似错误的其他应用程序,并认为我可能只能添加异常:

   #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

我是处理Python的新手,所以当我在黑暗中拍摄时,如果有人能指出我正确的方向,我会非常感激。

0 个答案:

没有答案