littlebot
Published on 2025-04-11 / 4 Visits
0

【源码】基于Python的文档图像分析与识别工具包

项目简介

vkit是面向计算机视觉领域,专注于文档图像分析与识别方向的Python工具包。其目的是为开发者提供便捷的数据处理和增强能力,让开发者能将更多精力投入到数据治理策略、算法模型设计与调优等更有价值的工作中。

项目的主要特性和功能

  1. 丰富的数据增强策略
    • 光度畸变:支持各类色彩空间操作(通道重组、色调和饱和度调整)以及各类噪音操作(高斯、泊松、脉冲和斑点噪声叠加)。
    • 几何畸变:支持常见仿射变换(旋转、倾斜、剪切)和非线性变换(Similarity MLS、基于相机模型的3D曲面和翻折效果),且在几何畸变过程中,能确保图片与各种标注数据类型的一致变换。
  2. 全面的数据类型封装与可视化支持
    • 图片类型:基于PIL封装,支持各类图片的读写操作。
    • 标注类型:提供蒙板、评分图、框、多边形等标注类型的封装。
  3. 工业级代码质量
    • 代码自动补全与类型检查:为开发提供友好的代码提示和类型检查,提升开发体验。
    • 包管理与依赖管理:具备成熟的包管理和依赖管理机制,方便项目的维护和部署。
    • 自动化检查与分析:基于flake8进行自动化风格检查,基于pyright进行静态类型分析。

安装使用步骤

安装

Python版本要求为3.8或3.9。 - 开发版本:安装追踪最新commit的版本。 bash pip install python-vkit-nightly - 稳定版本:安装已发布的稳定版本。 bash pip install python-vkit

使用

几何畸变示例

```python from vkit.image.type import VImage from vkit.augmentation.geometric_distortion import ( CameraModelConfig, CameraCubicCurveConfig, camera_cubic_curve, )

def run(image_file, output_file): image = VImage.from_file(image_file) config = CameraCubicCurveConfig( curve_alpha=60, curve_beta=-60, curve_direction=0, curve_scale=1.0, camera_model_config=CameraModelConfig( rotation_unit_vec=[1.0, 0.0, 0.0], rotation_theta=30, ), grid_size=10, ) result = camera_cubic_curve.distort(config, image) result.image.to_file(output_file) 可通过`fireball`直接调用上述示例:bash fib vkit_case.vkit_doc_helper.demo_geo:run \ --image_file="REQUIRED" \ --output_file="REQUIRED" ```

光度畸变示例

```python from vkit.image.type import VImage from vkit.augmentation.photometric_distortion import ( MeanShiftConfig, mean_shift, )

def run(image_file, output_file): image = VImage.from_file(image_file) config = MeanShiftConfig(delta=100) new_image = mean_shift.distort_image(config, image) new_image.to_file(output_file) 可通过`fireball`直接调用上述示例:bash fib vkit_case.vkit_doc_helper.demo_pho:run \ --image_file="REQUIRED" \ --output_file="REQUIRED" ```

下载地址

点击下载 【提取码: 4003】【解压密码: www.makuang.net】