Skip to content

Commit

Permalink
The following code is slow, "self.cap.set(cv2.CAP_PROP_POS_FRAMES, se…
Browse files Browse the repository at this point in the history
…lf.vid_stride * (self.frame + 1)) # read at vid_stride".
  • Loading branch information
mucunwuxian committed Sep 19, 2022
1 parent fda8aa5 commit e6d9ced
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions utils/dataloaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,9 @@ def __next__(self):
if self.video_flag[self.count]:
# Read video
self.mode = 'video'
ret_val, im0 = self.cap.read()
self.cap.set(cv2.CAP_PROP_POS_FRAMES, self.vid_stride * (self.frame + 1)) # read at vid_stride
for _ in range(self.vid_stride):
self.cap.grab()
ret_val, im0 = self.cap.retrieve()
while not ret_val:
self.count += 1
self.cap.release()
Expand Down

0 comments on commit e6d9ced

Please sign in to comment.