video.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:odin 作者: imito 项目源码 文件源码
def read(path, boxes=None):
  """
  Return
  ------
  Always return 3D images
  (n_frames, channels, width, height)
  """
  import imageio
  vid = imageio.get_reader(path)
  metadata = vid.get_meta_data()
  fps = metadata['fps']
  nb_frames = metadata['nframes']
  if boxes is not None:
    pass
  print(nb_frames)
  exit()
  try:
    frames = []
    for i in vid:
      # it is bizzare why width and height are swapped
      if i.ndim == 3: # swap channel first
        i = i.transpose(2, 1, 0)
      else:
        i = np.expand_dims(i.transpose(1, 0), 1)
      frames.append(i)
  except RuntimeError:
    pass
  frames = np.array(frames, dtype=frames[0].dtype)
  return frames, fps
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号