## **Katna**: Tool for automating video keyframe extraction, video compression, Image Autocrop and Smart image resize tasks
<img src="docs/source/logo.png" alt="logo" width="200"/>
### Resources
* Homepage and Reference: <https://katna.readthedocs.io/>
### Description
Katna automates the boring, error prone task of videos key/best frames extraction,
video compression and manual time consuming task of image cropping and resizing using ML.
In short, you may want to consider using Katna library if you have following tasks:
1. You have video/videos from who you want to extract keyframe/keyframes.
Please note 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.
Take an example of this video and some of the top keyframes extracted using Katna.
[![IMAGE ALT TEXT HERE](docs/source/images/tide_video_thumnail.jpg)](https://www.youtube.com/watch?v=zpaLHwwYxE8)
<p align="center"><img src="docs/source/images/arrow_down.jpeg" alt="arrow down" width="20"/></p>
![Image of keyframe extracted using Katna](docs/source/images/keyframe_extraction.jpg "Image of keyframe extracted using Katna")
2. You have video/videos you want to compress down to smaller size. (e.g. You have video with let's say 1 GB Size but you want to compress it down as small as possible.)
3. You have image/images which you want to smartly resize to a target resolution.
(e.g. 500x500, 1080p (1920x1080) etc.)
![Katna Image resize](docs/source/images/katna_image_resize.jpg "Katna Image resize")
4. You have image/images from which you want to intelligently extract a crop with a target resolution.
(e.g. Get a crop of size 500x500 from image of size 1920x1080)
![Katna Image crop](docs/source/images/katna_image_crop.jpg "Katna Image crop")
5. You want to extract a crop of particular aspect ratio e.g. 4:3 from your input image/images.
(e.g. Get a crop of aspect ratio 1:1 from image of resolution 1920x1080 (16:9 aspect ratio image))
6. You want to resize a video to particular aspect ratio e.g. 16:9 (Landscape), to lets say to 1:1 (square). Please note that this feature is currently **experimental** and needs additional compiling and configuration of google [mediapipe library](https://github.com/google/mediapipe).
[![ICEGov original video with 16:9 aspect ratio](docs/source/images/icegov_original.jpeg)](https://www.youtube.com/watch?v=-GFabrw3Csk)
<p align="center"><img src="docs/source/images/arrow_down.jpeg" alt="arrow down" width="20"/></p>
[![ICEGov resized video with 1:1 aspect ratio](docs/source/images/icegov_1_1_thumbnail.jpeg)](https://www.youtube.com/watch?v=P0D5WPv63RY)
Katna is divided into two modules
* Video module.
* Image module.
Video Module:
-------------
This module handles the task(s) for key frame(s) extraction and video compression.
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 for key-frame extraction**
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)
Video compression is handled using ffmpeg library. Details about which could be read in [Katna.video_compressor module](https://katna.readthedocs.io/en/latest/understanding_katna.html#katna-video-compressor) section.
Since version 0.8.0 of Katna we are extending smart resize features to videos with the help of Google's Mediapipe project. To know more about this please refer to documentation [Video Smart Resize using Katna]
(https://katna.readthedocs.io/en/latest/understanding_katna.html#katna-video-resize). Please note that this feature is an optional experimental feature. And might be subject to removal/modifications at later versions. Also you also need to install Google's Mediapipe library, Specially autoflip binary for this to work. Please refer to [Link](https://katna.readthedocs.io/en/latest/tutorials_video_smart_resize.html#tutorials-video-smart-resize) for how to install and configure mediapipe to be used with katna.
Image Module:
-------------
This module handles the task(s) related to smart cropping and image resizing.
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
Similar to Smart crop Katna image module supports **Smart image resizing** feature. Given an input image it can resize image to target resolution with simple resizing if aspect ratio is same for input and target image. If aspect ratio is different than smart image resize will first crops biggest good quality crop in target resolution and then resizes image in target resolution. This ensures image resize without actually skewing input image. *Please not that if aspect ratio of input and output image are not same katna image_resize can lead to some loss of image content*
**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.7
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 a
没有合适的资源?快使用搜索试试~ 我知道了~
用于自动执行常见视频关键帧提取、视频压缩和图像自动裁剪/图像调整大小任务的工具_python_代码_下载
共95个文件
py:38个
jpeg:18个
rst:10个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 112 浏览量
2022-06-15
01:05:20
上传
评论 1
收藏 16.16MB ZIP 举报
温馨提示
Katna 使用机器学习自动执行视频关键帧/最佳帧提取、视频压缩和手动耗时的图像裁剪和调整大小任务等枯燥且容易出错的任务。 简而言之,如果您有以下任务,您可能需要考虑使用 Katna 库: 您有要从中提取关键帧/关键帧的视频/视频。请注意,关键帧被定义为视频流的代表性帧,这些帧提供了最准确和最紧凑的视频内容摘要。以该视频为例,以及使用 Katna 提取的一些最重要的关键帧。 图像替代文字在这里 向下箭头 使用 Katna 提取的关键帧图像 您有视频/视频要压缩到更小的尺寸。(例如,您有 1 GB 大小的视频,但您希望将其压缩到尽可能小。) 您有图像/图像要巧妙地调整为目标分辨率。(例如 500x500、1080p (1920x1080) 等) Katna 图片调整大小 您有图像/图像,您希望从中智能地提取具有目标分辨率的裁剪。(例如,从尺寸为 1920x1080 的图像中获取尺寸为 500x500 的作物) Katna 图像裁剪 您想从输入图像/图像中提取特定纵横比的裁剪,例如 4:3。(例如,从分辨率为 1920x1080 的图像(16:9 纵横比图像)中获取纵横比
资源详情
资源评论
资源推荐
收起资源包目录
katna-master.zip (95个子文件)
katna-master
.readthedocs.yml 668B
example_image.py 2KB
Katna
image_features
face_feature.py 6KB
edge_feature.py 1KB
saliency_feature.py 1KB
feature.py 787B
__init__.py 16B
video.py 31KB
filter_list.py 2KB
mediapipe.py 11KB
image_selector.py 12KB
helper_functions.py 6KB
feature_list.py 2KB
image_filters
__init__.py 16B
filter.py 604B
text_detector.py 11KB
mediapipe_autoflip.pbtxt 6KB
frame_extractor.py 9KB
decorators.py 6KB
__init__.py 93B
crop_rect.py 2KB
video_compressor.py 7KB
crop_selector.py 6KB
image.py 23KB
writer.py 6KB
config.py 11KB
crop_extractor.py 14KB
version.py 22B
exceptions.py 559B
docs
make.bat 799B
requirements.txt 30B
Makefile 638B
source
troubleshooting.rst 4KB
Katna.rst 3KB
images
katna_image_resize.jpg 70KB
icegov_original.jpeg 143KB
keyframe_extraction.jpg 63KB
arrow_down.jpeg 4KB
icegov_1_1_thumbnail.jpeg 96KB
python_3.9_Keyframe_on_30_videos.png 33KB
python_3.8_Keyframe_on_30_videos.png 34KB
python_3.7_Keyframe_on_30_videos.png 18KB
mediapipe_autoflip_integration.jpeg 56KB
tide_video_thumnail.jpg 86KB
python_3.6_Keyframe_on_30_videos.png 18KB
katna_image_crop.jpg 27KB
conf.py 2KB
installation.rst 491B
how_to_guide.rst 11KB
modules.rst 55B
tutorials_video.rst 10KB
debugging_katna.rst 39B
logo.png 40KB
index.rst 7KB
tutorials_image.rst 12KB
understanding_katna.rst 11KB
_static 0B
example_video_compression.py 919B
example_image_resize_from_dir.py 1KB
example_image_resize.py 1KB
tests
image_similarity.py 5KB
test_image.py 10KB
data
codec_error_video.mp4 545KB
extracted_img_5.jpeg 65KB
test_image.jpeg 269KB
extracted_img_1.jpeg 45KB
bird_img_for_crop.jpg 243KB
extracted_img_10.jpeg 34KB
extracted_img_8.jpeg 73KB
extracted_img_7.jpeg 33KB
extracted_img_2.jpeg 91KB
test-image-oldman.jpg 423KB
extracted_img_6.jpeg 33KB
pos_video.mp4 1.3MB
extracted_img_3.jpeg 34KB
extracted_img_4.jpeg 36KB
23018877.jpg 343KB
Tidead.mp4 11.7MB
test_image_for_text.jpeg 280KB
image_for_text.png 5KB
extracted_img_9.jpeg 46KB
23018877_crop.jpg 97KB
extracted_img_11.jpeg 45KB
extracted_img_0.jpeg 32KB
test_all_video.py 9KB
__init__.py 0B
example_video.py 2KB
install.sh 25B
example_video_smart_resize.py 2KB
setup.cfg 68B
setup.py 3KB
.gitignore 2KB
README.md 12KB
LICENSE.txt 1KB
katna.yml 2KB
共 95 条
- 1
快撑死的鱼
- 粉丝: 1w+
- 资源: 9156
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0