Add function to extract evenly spaced frames from a video#155
Open
GauravSRC wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
extract_frames_uniformtoethology.io.video-- a functionthat extracts a user-specified number of evenly spaced frames from a
video file, optionally restricted to a time interval
[start_time, end_time].What is new
ethology/io/video.py-- new module containingextract_frames_uniform. Timestamps are computed withnumpy.linspaceover the requested interval; each timestamp isconverted to the nearest frame index and sought with
cv2.CAP_PROP_POS_FRAMESfor codec-agnostic reliability.Output frames are saved as JPEG files named
frame_NNNN_tT.TTTs.jpg.ethology/io/__init__.py-- exportsextract_frames_uniform.tests/fixtures/video.py-- fixture that builds a 30-framesynthetic AVI video (10 fps, 3 s, 64×64 px) in
tmp_pathforuse in tests.
tests/test_unit/test_io/test_video.py-- unit tests coveringcorrect frame counts, file existence, filename format, automatic
output-directory creation, time-interval extraction, and all
invalid-input error paths.
opencv-pythonadded to project dependencies.How to verify
pytest tests/test_unit/test_io/test_video.py -v
Checklist