Skip to content

Add function to extract evenly spaced frames from a video#155

Open
GauravSRC wants to merge 1 commit into
neuroinformatics-unit:mainfrom
GauravSRC:issue-6/extract-frames-uniform
Open

Add function to extract evenly spaced frames from a video#155
GauravSRC wants to merge 1 commit into
neuroinformatics-unit:mainfrom
GauravSRC:issue-6/extract-frames-uniform

Conversation

@GauravSRC
Copy link
Copy Markdown

Description

Adds extract_frames_uniform to ethology.io.video -- a function
that 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 containing
    extract_frames_uniform. Timestamps are computed with
    numpy.linspace over the requested interval; each timestamp is
    converted to the nearest frame index and sought with
    cv2.CAP_PROP_POS_FRAMES for codec-agnostic reliability.
    Output frames are saved as JPEG files named
    frame_NNNN_tT.TTTs.jpg.
  • ethology/io/__init__.py -- exports extract_frames_uniform.
  • tests/fixtures/video.py -- fixture that builds a 30-frame
    synthetic AVI video (10 fps, 3 s, 64×64 px) in tmp_path for
    use in tests.
  • tests/test_unit/test_io/test_video.py -- unit tests covering
    correct frame counts, file existence, filename format, automatic
    output-directory creation, time-interval extraction, and all
    invalid-input error paths.
  • opencv-python added to project dependencies.

How to verify

pytest tests/test_unit/test_io/test_video.py -v

Checklist

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

Successfully merging this pull request may close these issues.

1 participant