Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PY-647][external]Fixed cv2 import statement #754

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions darwin/dataset/download_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ def _download_and_extract_video_segment(
def _extract_frames_from_segment(path: Path, manifest: dt.SegmentManifest) -> None:
# import cv2 here to avoid dependency on OpenCV when not needed if not installed as optional extra
try:
from cv2 import VideoCapture # pylint: disable=import-outside-toplevel
from cv2 import VideoCapture, imwrite # pylint: disable=import-outside-toplevel
except ImportError as e:
raise MissingDependency(
"Missing Dependency: OpenCV required for Video Extraction. Install with `pip install darwin-py\[ocv]`"
Expand All @@ -679,7 +679,7 @@ def _extract_frames_from_segment(path: Path, manifest: dt.SegmentManifest) -> No
if frame_index in frames_to_extract:
visible_frame = frames_to_extract.pop(frame_index)
frame_path = path.parent / f"{visible_frame:07d}.png"
cv2.imwrite(str(frame_path), frame)
imwrite(str(frame_path), frame)
if not frames_to_extract:
break
frame_index += 1
Expand Down
Loading