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
- Homepage and Reference: https://katna.readthedocs.io/
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
- Frame that are sufficiently different from previous ones using absolute differences in LUV colorspace
- Brightness score filtering of extracted frames
- Entropy/contrast score filtering of extracted frames
- K-Means Clustering of frames using image histogram
- 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
- Edge, saliency and Face detection features are detected in the input image
- All the crops with specified dimensions are extracted with calculation of score for each crop wrt to extracted features
- 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
- Install Python 3
- pip install katna
Install from source
-
Install git
-
Install Anaconda or Miniconda Python
-
Open terminal
-
Clone repo from here https://github.com/keplerlab/Katna.git
-
Change the directory to the directory where you have cloned your repo
$cd path_to_the_folder_repo_cloned
-
Create a new anaconda environment if you are using anaconda python distribution
conda create --name katna python=3.7 source activate katna
-
Run the setup:
python setup.py install
Error handling and updates
-
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.
-
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.
-
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
-
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()
-
On windows, ensure that anaconda has admin rights if installing with anaconda as it fails with the write permission while installing some modules.
-
Python version 3.8 not supported due to the numpy and moviepy errors with this python version.
-
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
- Refer to quickstart section in Katna Reference from https://katna.readthedocs.io/
Attributions
- We have used the SAD (Sum of absolute difference) code from https://github.com/amanwalia92/KeyFramesExtraction
- We have used project Smartcrop https://github.com/jwagner/smartcrop.js/ for Smart crop feature in Katna Image module
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file katna-0.4.3.tar.gz
.
File metadata
- Download URL: katna-0.4.3.tar.gz
- Upload date:
- Size: 31.8 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5704319024e84fe69de646f159467052ae8f346eca459673ad0695d238d71da6 |
|
MD5 | 9afccd37f3be9cb0ce3638f681fc5767 |
|
BLAKE2b-256 | f4ad620d80c67e41ddc177199a334f7088f10ecd927f5d10453578306253d179 |
File details
Details for the file katna-0.4.3-py3.7.egg
.
File metadata
- Download URL: katna-0.4.3-py3.7.egg
- Upload date:
- Size: 94.1 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06f34d5cbbce408a33e05d4980b12f40f692308907f90ea9ec951112518444cf |
|
MD5 | 77c546f24efdb4fe701313defbb970f8 |
|
BLAKE2b-256 | 98c89848f5db5a27569372ab4d8bb76b6030915e3061e4fce67b043c8f2a8c96 |
File details
Details for the file katna-0.4.3-py3-none-any.whl
.
File metadata
- Download URL: katna-0.4.3-py3-none-any.whl
- Upload date:
- Size: 41.0 kB
- Tags: Python 3
- 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53b36a8a9539ac7d4e32f9aa0c18ffdb4cb1b9bd3dbe1e642b7e339f6b5229e8 |
|
MD5 | eb24e3dc99634dd82a499d12eb5c0dc5 |
|
BLAKE2b-256 | 2819f79104a3dbdfa1403da4264e883a0fb7eb8ec321256f14f38248b1bf261a |