Skip to content

Commit

Permalink
consider frame_ids=None in Video.init_video_reader
Browse files Browse the repository at this point in the history
  • Loading branch information
HanxSmile committed Apr 11, 2023
1 parent d075e04 commit 7df23d1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dsdl/geometry/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .utils import video_decode, video_encode
from fastjsonschema import compile
import numpy as np
from typing import Optional


def _compile_schema(schema):
Expand Down Expand Up @@ -134,7 +135,7 @@ def to_bytes(self):
"""
return io.BytesIO(self._reader.read(self._loc))

def init_video_reader(self, backend=DEFAULT_BACKEND, **kwargs):
def init_video_reader(self, backend: str = DEFAULT_BACKEND, **kwargs):
assert backend in self.ALL_BACKENDS
all_args = self.ENCODE_DEFAUTL_KWARGS[backend]
all_args.update(kwargs)
Expand All @@ -146,12 +147,14 @@ def init_video_reader(self, backend=DEFAULT_BACKEND, **kwargs):
self.frame_num = frame_num
return video_reader, frame_num

def to_array(self, frame_ids: np.ndarray, **kwargs):
def to_array(self, frame_ids: Optional[np.ndarray] = None, **kwargs):
"""Turn Video object to a numpy.ndarray list.
Returns:
The `np.ndarray` object of the current image.
"""
if frame_ids is None:
frame_ids = np.arange(0, self.frame_num)
all_args = self.DECODE_DEFAULT_KWARGS[self.backend]
all_args.update(kwargs)
self.DECODE_SCHEMA[self.backend](all_args)
Expand Down

0 comments on commit 7df23d1

Please sign in to comment.