Skip to content

Commit

Permalink
modified videodataset for window multiprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
JK-rez committed Feb 2, 2025
1 parent 8ac8e0d commit 068f3be
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion monai/data/video_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,13 @@ def get_fps(self) -> int:
def get_frame(self) -> Any:
"""Get next frame. For a file, this will be the next frame, whereas for a camera
source, it will be the next available frame."""
ret, frame = self._get_cap().read()
#Assign explicit videocapture object to cap to realease file to avoid error in multiprocessing
if self.multiprocessing:
cap = self._get_cap()
ret, frame = cap.read()
cap.release()
else:
ret, frame = self._get_cap().read()
if not ret:
raise RuntimeError("Failed to read frame.")
# Switch color order if desired
Expand Down

0 comments on commit 068f3be

Please sign in to comment.