Skip to content

Commit 068f3be

Browse files
committed
modified videodataset for window multiprocessing
1 parent 8ac8e0d commit 068f3be

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

monai/data/video_dataset.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,13 @@ def get_fps(self) -> int:
140140
def get_frame(self) -> Any:
141141
"""Get next frame. For a file, this will be the next frame, whereas for a camera
142142
source, it will be the next available frame."""
143-
ret, frame = self._get_cap().read()
143+
#Assign explicit videocapture object to cap to realease file to avoid error in multiprocessing
144+
if self.multiprocessing:
145+
cap = self._get_cap()
146+
ret, frame = cap.read()
147+
cap.release()
148+
else:
149+
ret, frame = self._get_cap().read()
144150
if not ret:
145151
raise RuntimeError("Failed to read frame.")
146152
# Switch color order if desired

0 commit comments

Comments
 (0)