Skip to content

video generator with start and end position feature - #162

Merged
SkalskiP merged 6 commits into
roboflow:mainfrom
hardikdava:video_generator_extended
Jun 28, 2023
Merged

SkalskiP merged 6 commits into
roboflow:mainfrom
hardikdava:video_generator_extended

Conversation

@hardikdava

Copy link
Copy Markdown
Contributor

Description

Related to #160

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Docs

  • Docs updated? What were the changes:

@hardikdava

Copy link
Copy Markdown
Contributor Author

@SkalskiP Please review it and merge it. I think docs needs to update for start and end argument.

@SkalskiP

Copy link
Copy Markdown
Collaborator

Awesome! 🔥 @hardikdava, did you test that on some example videos?

@hardikdava

hardikdava commented Jun 28, 2023 •

Copy link
Copy Markdown
Contributor Author

@SkalskiP I did some testing with various input parameters. It seems to work fine. I tried to improve the function with simple logic. Feel free to change if required.

Test Script:

import supervision as sv
import cv2

video_path = "path to your video"

for frame in sv.get_video_frames_generator(source_path=video_path, stride=10, start=0, end=500):
    cv2.imshow("Result", frame)
    cv2.waitKey(1)

@hardikdava

Copy link
Copy Markdown
Contributor Author

Hi @SkalskiP, I am wondering why these checks are failing. Do you know about it?

@hardikdava

Copy link
Copy Markdown
Contributor Author

@SkalskiP I have a feeling that yield is slower compare to normal video reading.

@SkalskiP

Copy link
Copy Markdown
Collaborator

I am wondering why these checks are failing. Do you know about it?

We already have an issue to take a look at it #138

I have a feeling that yield is slower compare to normal video reading.

Yup. It is because you initially used video.set 2x. Once to set the initial position and once in the loop. I refactored it to use video.set only once.

@SkalskiP SkalskiP self-assigned this Jun 28, 2023
@SkalskiP SkalskiP added API:video Video API version: 0.11.0 Feature to be added in `0.11.0` release enhancement New feature or request labels Jun 28, 2023
@SkalskiP

SkalskiP commented Jun 28, 2023 •

Copy link
Copy Markdown
Collaborator

@hardikdava There was also another bug when end was None`. I managed to fix it. Could you take a look at the code once again and maybe test it on your vid once again? I think everything works now, but it never hurts to have multiple people looking at the code.

@hardikdava

Copy link
Copy Markdown
Contributor Author

@SkalskiP I see a major bug. The function is returning different ending frame when we have different start value. Ideally, it should return same frame when end value is same.
For example,

for frame in sv.get_video_frames_generator(source_path=video_path, stride=10, start=499, end=500):
and 
for frame in sv.get_video_frames_generator(source_path=video_path, stride=10, start=100, end=500):

It should return the same frame in both case but it does not.
AFK for 1 hour.

@SkalskiP

Copy link
Copy Markdown
Collaborator

Oh I don’t think it is a bug. We return different frame at the end because total frame count is not divisible by stride. If you would use stride=1 it would return the same last frame.

@hardikdava

Copy link
Copy Markdown
Contributor Author

@SkalskiP I tested the code. It seems to work fine without any issue. Should we start discussing next task?

@SkalskiP

Copy link
Copy Markdown
Collaborator

Yeah! Let's do it tomorrow. Today I need to wrap a few things before 0.11.0 release :)

@hardikdava

Copy link
Copy Markdown
Contributor Author

Okay. Let's do it tomorrow then. Can't wait to contribute more to the community.

@SkalskiP
SkalskiP merged commit c74efc4 into roboflow:main Jun 28, 2023
@hardikdava
hardikdava deleted the video_generator_extended branch June 29, 2023 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API:video Video API enhancement New feature or request version: 0.11.0 Feature to be added in `0.11.0` release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants