【问题标题】:'numpy.ndarray' object is not callable?'numpy.ndarray' 对象不可调用?
【发布时间】:2019-04-07 10:50:11
【问题描述】:

运行此脚本:

import time
import picamera
import picamera.array
import numpy as np

with picamera.PiCamera() as camera:
    with picamera.array.PiBayerArray(camera) as stream:
        camera.capture(stream, 'jpeg', bayer=True)
        # Demosaic data and write to output (just use stream.array if you
        # want to skip the demosaic step)
        output = (stream.array() >> 2).astype(np.uint8)
        with open('image.jpg', 'wb') as f:
            output.tofile(f)

给出以下错误:

Traceback (most recent call last):
  File "numpy_simple.py", line 11, in <module>
    output = (stream.array() >> 2).astype(np.uint8)
TypeError: 'numpy.ndarray' object is not callable

运行时:

output = (stream.demosaic() >> 2).astype(np.uint8)
        with open('image.data', 'wb') as f:
            output.tofile(f)

没有给出任何错误。

我有点困惑。

【问题讨论】:

    标签: arrays python-3.x numpy demosaicing


    【解决方案1】:

    array 是一个属性,而不是一个方法。你不需要调用它。

    使用stream.array,而不是stream.array()

    来源:PiArrayOutput,这是PiBayerArray的基类。

    相反,.demosaic() 是一个实例方法,这就是为什么你需要调用它来获取它的返回值。

    【讨论】:

      猜你喜欢
      • 2019-09-04
      • 2021-06-11
      • 2017-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-01
      相关资源
      最近更新 更多