ValueError:append_data需要ndarray作为第一个arg(Imageio)

时间:2019-02-20 17:23:56

标签: python opencv computer-vision python-imageio

我正在尝试使用自定义函数(称为Digit_REcognition)检测对象,该函数将图像作为输入并返回与已识别类的边界框相同的图像:

reader = imageio.get_reader(video_path)

# Extract metadata
fps = reader.get_meta_data()['fps']

# Create the new video
writer = imageio.get_writer('output_1.mp4', fps = fps)

cap = cv2.VideoCapture(video_path)
length = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))

#Apply detect function on each frame
progress = 0
for frame in reader:

    frame = Digit_Recognition(frame)
    writer.append_data(frame)

    progress += 1
    print("Processed frames:", round(progress/length * 100, 2), "%,")

writer.close()

print("Exection Done")

我发现了两个主要问题,即:

  1. 警告:root用户:警告:读取的帧大小(1080,1440)与源帧的大小(1440,1080)不同。

  2. 进度持续追赶100%

3。。经过几次迭代,在完成编写任务之前,它会引发以下错误:

*File "<ipython-input-3-36cc68a9710d>", line 165, in Complete_Model
    writer.append_data(frame)

  File "/anaconda3/lib/python3.6/site-packages/imageio/core/format.py", line 477, in append_data
    raise ValueError('append_data requires ndarray as first arg')

ValueError: append_data requires ndarray as first arg*

如何解决错误,但更重要的是,更重要的是,是第三个问题?

P.s。我正在使用.mov作为输入视频

0 个答案:

没有答案