Skip to content

Commit

Permalink
fix: import cv2 conditionally on use of Video tools
Browse files Browse the repository at this point in the history
  • Loading branch information
dbirman committed Nov 25, 2023
1 parent a15e72f commit 24e5c3e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion API/oursin/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import PIL
from PIL import Image

import cv2
import numpy as np

import io
Expand Down Expand Up @@ -350,6 +349,11 @@ async def capture_video(self, file_name, start_rotation, end_rotation, frame_rat
--------
>>> await urchin.camera.main.capture_video('output.mp4', start_rotation=[22.5, 22.5, 225], end_rotation=[22.5, 22.5, 0])
"""
try:
import cv2
except:
raise Exception('Please install cv2 by running `pip install opencv-python` in your terminal to use the Video features')

fourcc = cv2.VideoWriter_fourcc(*'mp4v')
out = cv2.VideoWriter(file_name, fourcc, frame_rate, size)

Expand Down

0 comments on commit 24e5c3e

Please sign in to comment.