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

freq does not work consistently across the whole video file #26

Open
Cutuchiqueno opened this issue May 12, 2020 · 0 comments
Open

freq does not work consistently across the whole video file #26

Cutuchiqueno opened this issue May 12, 2020 · 0 comments

Comments

@Cutuchiqueno
Copy link

Cutuchiqueno commented May 12, 2020

Describe the bug
utils._which_frames does not filter frames as one would expect with respect to the freq-Attribute. It applies freq only within a present batch but not across batches for the entire movie. This leads to inconsistent steps in the output data.

To Reproduce

dextra = DataExtraction(FrameInput(input_path="./VID-20191006-WA0014.mp4"))  # default bsize=256
dextra.run_annotators([LchAnnotatorRay(freq=10)], max_batch=2)  #my custom annotator, using utils._which_frames function

which gives me data for the frames: [0, 10, 20, ..., 240, 250, 256, 266, 276, ..., 500, 510]

you see wrong frame step after switching from batch 1 to batch 2. This makes sense when looking at the implementation of utils._which_frames:

return list(range(0, batch.bsize, freq))

Regardless of the starting point of the current batch, the selection of frames always starts with 0 and the first frame in the second batch is frame 256.

Expected behavior
The correct frame sequence in the above example should be [0, 10, 20, ..., 240, 250, 260, 270, ..., 500, 510].
The first frame of the second batch should be 260 which equates to the index 4 (not 0).

Desktop (please complete the following information):

  • Arch Linux
  • Python 3.7.1
  • dvt 0.3.3

Additional context
I developed a fix which for which I would make a pull request if you agree upon my expected behaviour. It works like this:

The freq minus the rest of bnum times the bsize divided by the freq for bnum greater than 0 otherwise 0.

if frames is None:
        # return list(range(0, batch.bsize, freq))
        first_frame = 0
        _, rest = divmod(batch.bnum * batch.bsize, freq)
        if rest != 0:
            first_frame = freq - rest
        return list(range(first_frame, batch.bsize, freq))

This works well for me so far.

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