Skip to content

Commit

Permalink
Add include_predictions parameter to FrameSet.save_video (#175)
Browse files Browse the repository at this point in the history
* Add include_predictions parameter to FrameSet.save_video

* lint
  • Loading branch information
pappacena authored Feb 8, 2024
1 parent 0974b03 commit 441a2bd
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions landingai/pipeline/frameset.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,11 @@ def to_numpy_array(self, image_src: str = "") -> np.ndarray:
----------
image_src : if empty the source image will be converted. Otherwise the image will be selected from `other_images`
"""
img = self.image if image_src == "" else self.other_images[image_src]
img = (
self.image
if image_src == "" or image_src not in self.other_images
else self.other_images[image_src]
)
return np.asarray(img)

def show_image(
Expand Down Expand Up @@ -610,7 +614,8 @@ def save_video(
video_file_path: str,
video_fps: Optional[int] = None,
video_length_sec: Optional[float] = None,
image_src: str = "",
image_src: str = "", # TODO: remove this parameter in next major version
include_predictions: bool = False,
) -> "FrameSet":
"""Save the FrameSet as an mp4 video file. The following example, shows to use save_video to save a clip from a live RTSP source.
```python
Expand Down Expand Up @@ -640,6 +645,14 @@ def save_video(
"""
if not video_file_path.lower().endswith(".mp4"):
raise NotImplementedError("Only .mp4 is supported")

if image_src:
warnings.warn(
"image_src keyword on FrameSet.save_video is deprecated. Use include_predictions instead."
)
if include_predictions:
image_src = "overlay"

total_frames = len(self.frames)
if total_frames == 0:
return self
Expand Down

0 comments on commit 441a2bd

Please sign in to comment.