Skip to main content

Katna is a tool that automates video key/best frames extraction.

Project description

Katna: Tool for automating common vide keyframe extraction and Image Autocrop tasks

Resources

Description

Katna automates the boring, error prone task of videos key/best frames extraction and manual time consuming task of image cropping.

Katna is divided into two modules namely video and image.

Video Module:

This module handles the task(s) related to key frame extraction.

Key-frames are defined as the representative frames of a video stream, the frames that provide the most accurate and compact summary of the video content.

Frame extraction and selection criteria

  1. Frame that are sufficiently different from previous ones using absolute differences in LUV colorspace
  2. Brightness score filtering of extracted frames
  3. Entropy/contrast score filtering of extracted frames
  4. K-Means Clustering of frames using image histogram
  5. Selection of best frame from clusters based on and variance of laplacian (image blur detection)

Image Module:

This module handles the task(s) related to smart cropping.

The Smart image cropping is happening in way that the module identifies the best part or the area where someone focus more and interprets this information while cropping the image.

Crop extraction and selection criteria

  1. Edge, saliency and Face detection features are detected in the input image
  2. All the crops with specified dimensions are extracted with calculation of score for each crop wrt to extracted features
  3. The crops will be passes through filters specified which will remove the crops which filter rejects

Supported Video and image file formats ##########################################

All the major video formats like .mp4,.mov,.avi etc and image formats like .jpg, .png, .jpeg etc are supported.

More selection features are in developement pipeline

How to install

Using pypi

  1. Install Python 3
  2. pip install katna

Install from source

  1. Install git

  2. Install Anaconda or Miniconda Python

  3. Open terminal

  4. Clone repo from here https://github.com/keplerlab/Katna.git

  5. Change the directory to the directory where you have cloned your repo

    $cd path_to_the_folder_repo_cloned
    
  6. Create a new anaconda environment if you are using anaconda python distribution

    conda create --name katna python=3
    source activate katna
    
  7. Run the setup:

    python setup.py install 
    

Error handling and updates

  1. Since Katna version 0.4.0 Katna video module is optimized to use multiprocessing using python multiprocessing module. Due to restrictions of multiprocessing in windows, For safe importing of main module in windows system, make sure “entry point” of the program is wrapped in name == 'main': as follows:

    from Katna.video import Video
    if __name__ == "__main__":
        vd = Video()
        # your code
    

    please refer to https://docs.python.org/2/library/multiprocessing.html#windows for more details.

  2. If input image is of very large size ( larger than 2000x2000 ) it might take a long time to perform Automatic smart cropping.If you encounter this issue, consider changing down_sample_factor from default 8 to larger values ( like 16 or 32 ). This will decrease processing time significantly.

  3. If you see "AttributeError: module 'cv2.cv2' has no attribute 'saliency'" error. Uninstall opencv-contrib by running command "python -m pip uninstall opencv-contrib-python" and then again install it by running command

    python -m pip install opencv-contrib-python
    
  4. If you see "FileNotFoundError: frozen_east_text_detection.pb file not found". Open python shell and follow below commands.

    from Katna.image_filters.text_detector import TextDetector
    td = TextDetector()
    td.download()
    
  5. On windows, ensure that anaconda has admin rights if installing with anaconda as it fails with the write permission while installing some modules.

  6. Python version 3.8 not supported due to the numpy and moviepy errors with this python version.

  7. If you get "RuntimeError: No ffmpeg exe could be found. Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable". Go to the imageio_ffmpeg-*.egg folder inside your site-packages folder, there's ffmpeg file inside binaries folder set it's path to environment variable.

How to use Library

  1. Refer to quickstart section in Katna Reference from https://katna.readthedocs.io/

Attributions

  1. We have used the SAD (Sum of absolute difference) code from https://github.com/amanwalia92/KeyFramesExtraction
  2. We have used project Smartcrop https://github.com/jwagner/smartcrop.js/ for Smart crop feature in Katna Image module

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

katna-0.4.1.4.tar.gz (31.3 kB view details)

Uploaded Source

Built Distributions

katna-0.4.1.4-py3.7.egg (86.0 kB view details)

Uploaded Source

katna-0.4.1.4-py3-none-any.whl (40.5 kB view details)

Uploaded Python 3

File details

Details for the file katna-0.4.1.4.tar.gz.

File metadata

  • Download URL: katna-0.4.1.4.tar.gz
  • Upload date:
  • Size: 31.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for katna-0.4.1.4.tar.gz
Algorithm Hash digest
SHA256 422ea24dcf21089bc2cdb4f4b96dd2019a4bd6b66216bb398e4d2f524f0d2f03
MD5 1a74ff492118e30154c39c96c14e25fd
BLAKE2b-256 57727137259e6251da0acd3c4e5838cdbf8054788a1bfbc555a62ddd49489c49

See more details on using hashes here.

File details

Details for the file katna-0.4.1.4-py3.7.egg.

File metadata

  • Download URL: katna-0.4.1.4-py3.7.egg
  • Upload date:
  • Size: 86.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.9

File hashes

Hashes for katna-0.4.1.4-py3.7.egg
Algorithm Hash digest
SHA256 56cc5d4b290c9d426df5bb1ea9b19d48a5bbdfd7f1b0b2547279e1dc19a03ca1
MD5 5d7e3990727a5c168be302b727b3ed40
BLAKE2b-256 4f9afe3d7e5d08e1bcbc7d9fab2ccb1fd30d5deea7f85bffff26a58b571beb42

See more details on using hashes here.

File details

Details for the file katna-0.4.1.4-py3-none-any.whl.

File metadata

  • Download URL: katna-0.4.1.4-py3-none-any.whl
  • Upload date:
  • Size: 40.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for katna-0.4.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 aa0585b558e984e6444f4a11c3734a05b1201516003d8f0a64fd1dfba5afc698
MD5 3209b2d9a426102e8d20a79ed695b240
BLAKE2b-256 923e5c2da199eea89f4698b46bb18b64a4e5d9f60cfaecf3d6165c45809e0923

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page