一个用于转换YOLOOBB和labelimgOBB格式的工具
Project description
labelimgobb2DOTA Converter
📋 功能特性
- 🔄 双向转换: 支持YOLOOBB ↔ labelimgOBB格式互转
- 🖼️ 图形界面: 直观易用的GUI界面
- ⌨️ 命令行工具: 适合批量处理和自动化
- 📦 数据集生成: 自动生成dataset.yaml和class_names.txt
- 🐍 Python API: 可直接在代码中调用
- ✅ 格式验证: 确保转换结果的准确性
- 📊 格式比较: 转换精度验证和差异报告
- 🏷️ 类别管理: 自动生成类别文件和数据集配置
- 📐 坐标转换: 支持归一化坐标和像素坐标转换
- 🎯 预设支持: 内置DOTA、COCO等常用数据集类别
🚀 安装方法
从PyPI安装
pip install labelimgobb2DOTA-converter
开发者安装
# 基本安装
pip install labelimgobb2DOTA-converter
# 开发者安装
pip install labelimgobb2DOTA-converter[dev]
从源码安装
git clone https://github.com/BIANG-qilie/labelimgobb2DOTA.git
cd labelimgobb2DOTA
pip install -e .
📖 使用指南
图形界面
启动GUI界面:
labelimgobb2DOTA-gui
或者:
from labelimgobb2DOTA_converter.gui import ConvertLabelsGUI
app = ConvertLabelsGUI()
app.mainloop()
命令行工具
交互模式
labelimgobb2DOTA-cli
直接转换
# YOLOOBB → labelimgOBB
labelimgobb2DOTA-cli --mode yolo2labelimg --input ./yolo_labels --output ./labelimg_labels --width 1920 --height 1080
# labelimgOBB → YOLOOBB
labelimgobb2DOTA-cli --mode labelimg2yolo --input ./labelimg_labels --output ./yolo_labels --width 1920 --height 1080
Python API
from labelimgobb2DOTA_converter import (
DOTA2labelimgOBB,
labelimgOBB2DOTA
)
# 单文件转换
DOTA2labelimgOBB('input.txt', 'output.txt', img_width=1920, img_height=1080)
# 批量转换
import glob
for file in glob.glob('*.txt'):
labelimgOBB2DOTA(file, f'converted_{file}', 1920, 1080)
📁 项目结构
labelimgobb2DOTA-converter/
├── labelimgobb2DOTA_converter/ # 主包
│ ├── __init__.py # 包初始化
│ │ ├── __init__.py
│ │ ├── core/ # 核心功能
│ │ │ ├── __init__.py
│ │ │ ├── converter.py # 格式转换器
│ │ │ └── obb_utils.py # OBB数学工具
│ │ ├── utils/ # 工具函数
│ │ │ ├── __init__.py
│ │ │ ├── file_utils.py # 文件处理
│ │ │ └── dataset_utils.py # 数据集工具
│ │ ├── gui/ # 图形界面
│ │ │ ├── __init__.py
│ │ │ ├── main_window.py # 主窗口
│ │ │ └── dialogs.py # 对话框
│ │ └── cli/ # 命令行接口
│ │ ├── __init__.py
│ │ └── main.py # CLI主程序
│ ├── tests/ # 测试文件
│ ├── examples/ # 示例文件
│ ├── docs/ # 文档
│ ├── pyproject.toml # 项目配置
│ └── README.md # 项目说明
🛠️ 开发指南
设置开发环境
git clone https://github.com/BIANG-qilie/labelimgobb2DOTA.git
cd labelimgobb2DOTA
# 创建虚拟环境
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# 安装开发依赖
pip install -e .[dev]
# 安装pre-commit钩子
pre-commit install
运行测试
# 运行所有测试
pytest
# 运行测试并生成覆盖率报告
pytest --cov=labelimgobb2DOTA_converter --cov-report=html
# 运行特定测试
pytest tests/test_converter.py
代码格式化
# 格式化代码
black labelimgobb2DOTA_converter/
# 检查代码风格
flake8 labelimgobb2DOTA_converter/
# 类型检查
mypy labelimgobb2DOTA_converter/
📄 文件格式说明
DOTA格式 ( Ultralytics 的 YOLO obb的数据格式 )
class_id x1 y1 x2 y2 x3 y3 x4 y4
- 坐标为归一化值(0-1之间)
- (x1,y1), (x2,y2), (x3,y3), (x4,y4)为四个顶点坐标
labelimgOBB格式
YOLO_OBB
class_id x_center y_center width height angle
- 第一行为固定标识符
- 坐标为像素值
- angle为角度(度数)
🤝 贡献指南
- Fork本项目
- 创建特性分支 (
git checkout -b feature/AmazingFeature) - 提交更改 (
git commit -m 'Add some AmazingFeature') - 推送到分支 (
git push origin feature/AmazingFeature) - 创建Pull Request
📝 更新日志
v0.1.0 (当前版本)
- ✨ 重构项目架构,采用模块化设计
- 🔧 添加命令行工具支持
- 📦 支持pip安装
- 🧪 添加单元测试
- 📚 完善文档和示例
- 🎯 支持数据集配置文件生成
📄 许可证
本项目采用MIT许可证 - 查看 LICENSE 文件了解详情
👨💻 作者
Blake Zhu - GitHub
�� 致谢
- 感谢所有为本项目贡献代码的开发者
- 感谢YOLO和labelimg项目的启发
如果这个项目对您有帮助,请给它一个⭐️
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 Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file labelimgobb2dota_converter-0.1.2.tar.gz.
File metadata
- Download URL: labelimgobb2dota_converter-0.1.2.tar.gz
- Upload date:
- Size: 28.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e14ab4b734c0826b27d5b6018011e0a84b0268e48fc9244cf1db19ffe905532b
|
|
| MD5 |
39d0dca2620072645966ed67abc4dea2
|
|
| BLAKE2b-256 |
a1efa6193473e015316514c4030454ddb8aaaa9c46e4262164ed7b25760b7805
|
File details
Details for the file labelimgobb2dota_converter-0.1.2-py3-none-any.whl.
File metadata
- Download URL: labelimgobb2dota_converter-0.1.2-py3-none-any.whl
- Upload date:
- Size: 27.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8223444cd417b304885a8592cb9ff1fd14a2554434f958b321810a664ff85d59
|
|
| MD5 |
3257e215f18fa37a127ba371b12acc3e
|
|
| BLAKE2b-256 |
3d05b6389352f60f354760804fadde515104fe1b8132d6ef0ccf25be77775449
|