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

Partial video frame reading becomes progressively slower #453

Open
KangByungwoo opened this issue Jul 24, 2023 · 0 comments
Open

Partial video frame reading becomes progressively slower #453

KangByungwoo opened this issue Jul 24, 2023 · 0 comments

Comments

@KangByungwoo
Copy link

KangByungwoo commented Jul 24, 2023

Hi,

If I run the below code:

v = pims.Video(avi_filename) # v.shape = (n_frames, H, W, 3)

pre_frames = 100
post_frames = 200

v2 = np.zeros((len(frame_idxs), pre_frames + post_frames, H, W))

for iter, frame_idx in enumerate(frame_idxs):
start_time = time.time()

start_frame = frame_idx - pre_frames 
end_frame = frame_idx + post_frames 

if start_frame >= 0 and end_frame <= num_frames:
    v2[trial_idx] = np.array(v[start_frame:end_frame])[...,0] # [...,0] b/c video is greyscale so last dim is redundant.


print('iter: {} ({:.2f})'.format(iter, time.time() - start_time))

The time for each for-loop iteration becomes progressively longer even though the number of frames read is fixed. For e.g,

iter: 0 (0.92)
iter: 1 (1.37)
iter: 2 (1.48)
iter: 3 (1.60)
iter: 4 (1.82)
iter: 5 (1.95)
iter: 6 (2.27)
iter: 7 (2.47)
iter: 8 (2.55)
iter: 9 (2.74)
...

Why is this so? Is there a workaround for this? Thank you!

@KangByungwoo KangByungwoo changed the title Partial video frame reading becomes progressively slower. Partial video frame reading becomes progressively slower Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant