我正在尝试使用 imageio API 读取帧。我有一个读者作为我收到的对象imageio.get_reader(video_path,"ffmpeg")
nframes =int(reader.get_length())
for ii in range(nframes):
while frame_q.qsize() > 500: # so that we dont use huge amounts of memory
time.sleep(1)
cur_img = reader.get_next_data()
frame_q.put(cur_img)
#shape = cur_img.shape
#noisy_img = np.uint8(cur_img.astype(np.float) + np.random.randn(*shape) * 20)
#frame_q.put(noisy_img)
if ii % 100 == 0:
print("%i / %i frames in queue" % (ii, nframes))
print("All %i frames in queue" % (nframes))
追溯:
Traceback (most recent call last):
File "/home/prashantb/anaconda3/envs/demo/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/home/prashantb/anaconda3/envs/demo/lib/python3.6/multiprocessing/process.py", line 93, in run
self._target(*self._args, **self._kwargs)
File "multiprocess_detect_actions.py", line 61, in read_frames
nframes =int(reader.get_length())
OverflowError: cannot convert float infinity to integer
最初,它nframe
是一个浮点值,然后我尝试将其转换为整数,但后来我得到了一个溢出错误。我将感谢您对此的建议。谢谢你。