你可以使用imageio.imread()
函数读取视频中的帧并转换为numpy图片数组。
举个例子:
import imageio# 读取视频文件
video = imageio.get_reader('video.mp4')
# 获取第10帧
frame = video.get_data(10)
# 将帧转换为numpy图片数组
frame_array = imageio.imread(frame)
注意:imageio.imread()
函数还可以直接读取图片文件并转换为numpy图片数组。