Git Product home page Git Product logo

sharp-frame-extractor's Introduction

Sharp Frame Extractor

Extracts sharp frames from a video by using a time window to detect the sharpest frame.

The idea of the extractor is to provide a simple tool to extract sharp frames from videos to be used in photogrammetry and volumetric capturing. The algorithm is currently based on the idea that the standard deviation represents a valid metric for how sharp a frame is. The value is calculated on an edge detection result which is by default created by a canny edge detection. The parameters for the canny edge detector are extracted per frame. To further enhance this detection, only the center of the frame is used (usually the focus of the scene).

Further ideas can be implemented, for example a sobel based method is already available.

Example

frames-all One hundred sharp frame extracted from an iPhone video.

from-to-trees The reconstruction of the one hundred frames compared with the original cherry tree.

You can read more about this example project over at behance.

Prerequisites

To install the package use the following pip command:

pip install git+https://github.com/cansik/[email protected]

Usage

Here you find an example command that extracts a frame every 300ms into ./frames folder:

sfextract --window 300 test.mov

It is also possible to extract a fix number of frames out of the video file. This example extracts 30 frames.

sfextract --frame-count 30 test.mov

Performance

The script tries to estimate the best CPU count to not overload the available RAM or the computer specifications. But it is possible to overwrite this estimation by the following flag:

# uses all available CPU
sfextract --frame-count 30 --force-cpu-count test.mov

Help

usage: sfextract [-h] [--method {canny,sobel}] [--window WINDOW]
                 [--frame-count FRAME_COUNT] [--all] [--crop CROP] [--min MIN]
                 [--output OUTPUT] [--format {jpg,png,bmp,gif,tif}]
                 [--cpu-count CPU_COUNT] [--force-cpu-count] [--preview]
                 [--debug]
                 video

Extracts sharp frames from a video by using a time window to detect the
sharpest frame.

positional arguments:
  video                 Path to the video input file.

optional arguments:
  -h, --help            show this help message and exit
  --method {canny,sobel}
                        Sharpness detection method (Default canny).
  --window WINDOW       Window in ms to slide over the video and detect
                        sharpest frame from.
  --frame-count FRAME_COUNT
                        Amount of output frames. If the value is >0 the
                        extractor calculates the window size to match the
                        output frames.
  --all                 Extracts all the frames of the video.
  --crop CROP           Crop to center factor for ROI sharpness detection.
  --min MIN             Minimum sharpness level which is dependent on the
                        detection method used.
  --output OUTPUT       Path where to store the frames.
  --format {jpg,png,bmp,gif,tif}
                        Frame output format.
  --cpu-count CPU_COUNT
                        How many CPU's are used for the extraction (by default
                        it is calculate by available RAM and frame count).
  --force-cpu-count     Forces to use exact CPU number.
  --preview             Only shows how many frames would be extracted.
  --debug               Shows debug frames and information.

About

MIT License - Copyright (c) 2021 Florian Bruggisser

sharp-frame-extractor's People

Contributors

cansik avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.