# annofabapi-3dpc-extensions
[![Build Status](https://app.travis-ci.com/kurusugawa-computer/annofabapi-3dpc-extensions.svg?branch=main)](https://app.travis-ci.com/kurusugawa-computer/annofabapi-3dpc-extensions)
[![PyPI version](https://badge.fury.io/py/annofabapi-3dpc-extensions.svg)](https://badge.fury.io/py/annofabapi-3dpc-extensions)
[![Python Versions](https://img.shields.io/pypi/pyversions/annofabapi-3dpc-extensions.svg)](https://pypi.org/project/annofabapi-3dpc-extensions/)
[![Documentation Status](https://readthedocs.org/projects/annofabapi-3dpc-extensions/badge/?version=latest)](https://annofabapi-3dpc-extensions.readthedocs.io/en/latest/?badge=latest)
[annofabapi](https://github.com/kurusugawa-computer/annofab-api-python-client)の3次元アノテーション用の拡張機能です。
# Install
* Python 3.9+
# Install
```
$ pip install annofabapi-3dpc-extensions
```
# Usage
cuboidアノテーションやセグメントアノテーションに対応したデータクラスを利用できます。
```python
from annofabapi.parser import SimpleAnnotationDirParser
from annofab_3dpc.annotation import (
CuboidAnnotationDetailDataV2,
EulerAnglesZXY,
SegmentAnnotationDetailData,
SegmentData,
convert_annotation_detail_data,
)
parser = SimpleAnnotationDirParser("tests/data/task1/input1.json")
result = parser.parse(convert_annotation_detail_data)
segment_annotation_data = result.details[0].data
cuboid_annotation_data = result.details[1].data
assert type(segment_annotation_data) == SegmentAnnotationDetailData
assert type(cuboid_annotation_data) == CuboidAnnotationDetailDataV2
### cuboid annotation
print(cuboid_annotation_data)
# => CuboidAnnotationDetailDataV2(shape=CuboidShapeV2(dimensions=Size(width=6.853874863204751, height=0.2929844409227371, depth=4.092537841193188), location=Location(x=-11.896872014598989, y=-3.0571381239812996, z=0.3601047024130821), rotation=EulerAnglesZXY(x=0, y=0, z=0), direction=CuboidDirection(front=Vector3(x=1, y=0, z=0), up=Vector3(x=0, y=0, z=1))), kind='CUBOID', version='2')
# オイラー角をクォータニオンに変換
print(cuboid_annotation_data.shape.rotation.to_quaternion())
# => [1.0, 0.0, 0.0, 0.0]
# クォータニオンからオイラー角に変換
print(EulerAnglesZXY.from([1.0, 0.0, 0.0, 0.0]))
# => EulerAnglesZXY(x=-0.0, y=0.0, z=0.0)
### segment annotation
print(segment_annotation_data)
# => SegmentAnnotationDetailData(data_uri='./input1/7ba51c15-f07a-4e29-8584-a4eaf3a6812a')
# セグメント情報が格納されたファイルを読み込む
with parser.open_outer_file(Path(segment_annotation_data.data_uri).name) as f:
dict_segmenta_data = json.load(f)
segment_data = SegmentData.from_dict(dict_segmenta_data)
assert type(segment_data) == SegmentData
assert len(segment_data.points) > 0
print(segment_data.points)
# => [130439, 130442, ... ]
```
# 開発者向けドキュメント
https://github.com/kurusugawa-computer/annofabapi-3dpc-extensions/blob/main/README_for_developer.md 参照
Raw data
{
"_id": null,
"home_page": "https://github.com/kurusugawa-computer/annofabapi-3dpc-extensions",
"name": "annofabapi-3dpc-extensions",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Kurusugawa Computer Inc.",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/91/7a/b9c92a9d70b6f271b15295ff7ddf80533bbe28256a1de55035d3f0db4bc7/annofabapi_3dpc_extensions-0.3.0.tar.gz",
"platform": null,
"description": "# annofabapi-3dpc-extensions\n[![Build Status](https://app.travis-ci.com/kurusugawa-computer/annofabapi-3dpc-extensions.svg?branch=main)](https://app.travis-ci.com/kurusugawa-computer/annofabapi-3dpc-extensions)\n[![PyPI version](https://badge.fury.io/py/annofabapi-3dpc-extensions.svg)](https://badge.fury.io/py/annofabapi-3dpc-extensions)\n[![Python Versions](https://img.shields.io/pypi/pyversions/annofabapi-3dpc-extensions.svg)](https://pypi.org/project/annofabapi-3dpc-extensions/)\n[![Documentation Status](https://readthedocs.org/projects/annofabapi-3dpc-extensions/badge/?version=latest)](https://annofabapi-3dpc-extensions.readthedocs.io/en/latest/?badge=latest)\n\n\n\n[annofabapi](https://github.com/kurusugawa-computer/annofab-api-python-client)\u306e3\u6b21\u5143\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u7528\u306e\u62e1\u5f35\u6a5f\u80fd\u3067\u3059\u3002\n\n# Install\n\n* Python 3.9+\n\n# Install\n\n```\n$ pip install annofabapi-3dpc-extensions\n```\n\n\n# Usage\n\ncuboid\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3084\u30bb\u30b0\u30e1\u30f3\u30c8\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u306b\u5bfe\u5fdc\u3057\u305f\u30c7\u30fc\u30bf\u30af\u30e9\u30b9\u3092\u5229\u7528\u3067\u304d\u307e\u3059\u3002\n\n```python\nfrom annofabapi.parser import SimpleAnnotationDirParser\n\nfrom annofab_3dpc.annotation import (\n CuboidAnnotationDetailDataV2,\n EulerAnglesZXY,\n SegmentAnnotationDetailData,\n SegmentData,\n convert_annotation_detail_data,\n)\n\nparser = SimpleAnnotationDirParser(\"tests/data/task1/input1.json\")\nresult = parser.parse(convert_annotation_detail_data)\n\nsegment_annotation_data = result.details[0].data\ncuboid_annotation_data = result.details[1].data\nassert type(segment_annotation_data) == SegmentAnnotationDetailData\nassert type(cuboid_annotation_data) == CuboidAnnotationDetailDataV2\n\n\n### cuboid annotation\n\nprint(cuboid_annotation_data)\n# => CuboidAnnotationDetailDataV2(shape=CuboidShapeV2(dimensions=Size(width=6.853874863204751, height=0.2929844409227371, depth=4.092537841193188), location=Location(x=-11.896872014598989, y=-3.0571381239812996, z=0.3601047024130821), rotation=EulerAnglesZXY(x=0, y=0, z=0), direction=CuboidDirection(front=Vector3(x=1, y=0, z=0), up=Vector3(x=0, y=0, z=1))), kind='CUBOID', version='2')\n\n# \u30aa\u30a4\u30e9\u30fc\u89d2\u3092\u30af\u30a9\u30fc\u30bf\u30cb\u30aa\u30f3\u306b\u5909\u63db\nprint(cuboid_annotation_data.shape.rotation.to_quaternion())\n# => [1.0, 0.0, 0.0, 0.0]\n\n# \u30af\u30a9\u30fc\u30bf\u30cb\u30aa\u30f3\u304b\u3089\u30aa\u30a4\u30e9\u30fc\u89d2\u306b\u5909\u63db\nprint(EulerAnglesZXY.from([1.0, 0.0, 0.0, 0.0]))\n# => EulerAnglesZXY(x=-0.0, y=0.0, z=0.0)\n\n\n### segment annotation\nprint(segment_annotation_data)\n# => SegmentAnnotationDetailData(data_uri='./input1/7ba51c15-f07a-4e29-8584-a4eaf3a6812a')\n\n# \u30bb\u30b0\u30e1\u30f3\u30c8\u60c5\u5831\u304c\u683c\u7d0d\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080\nwith parser.open_outer_file(Path(segment_annotation_data.data_uri).name) as f:\n dict_segmenta_data = json.load(f)\n segment_data = SegmentData.from_dict(dict_segmenta_data)\n assert type(segment_data) == SegmentData\n assert len(segment_data.points) > 0\n print(segment_data.points)\n # => [130439, 130442, ... ]\n\n```\n\n\n# \u958b\u767a\u8005\u5411\u3051\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\n\nhttps://github.com/kurusugawa-computer/annofabapi-3dpc-extensions/blob/main/README_for_developer.md \u53c2\u7167\n",
"bugtrack_url": null,
"license": null,
"summary": "annofabapi\u306e3DPC Editor\u7528\u306e\u62e1\u5f35\u6a5f\u80fd\u3067\u3059\u3002",
"version": "0.3.0",
"project_urls": {
"Homepage": "https://github.com/kurusugawa-computer/annofabapi-3dpc-extensions",
"Repository": "https://github.com/kurusugawa-computer/annofabapi-3dpc-extensions"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "180ad7a5c7402a01850cba94e420e584f2d11386a5db10c2071443be9a34d6d9",
"md5": "1ebdbe50fd9dfe336e1b1ae769427b50",
"sha256": "43f028fa94bf5de1824e6739b408e5cdc51b774fc8b840cdcf70ba34ead54614"
},
"downloads": -1,
"filename": "annofabapi_3dpc_extensions-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1ebdbe50fd9dfe336e1b1ae769427b50",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 7269,
"upload_time": "2025-01-07T09:06:32",
"upload_time_iso_8601": "2025-01-07T09:06:32.668820Z",
"url": "https://files.pythonhosted.org/packages/18/0a/d7a5c7402a01850cba94e420e584f2d11386a5db10c2071443be9a34d6d9/annofabapi_3dpc_extensions-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "917ab9c92a9d70b6f271b15295ff7ddf80533bbe28256a1de55035d3f0db4bc7",
"md5": "556a94aad673faad2d10a3f76d339157",
"sha256": "f7441d90431b2b1b2416a0db9edac24716261ebd1850366240cde8e031e8f98d"
},
"downloads": -1,
"filename": "annofabapi_3dpc_extensions-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "556a94aad673faad2d10a3f76d339157",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 7457,
"upload_time": "2025-01-07T09:06:33",
"upload_time_iso_8601": "2025-01-07T09:06:33.692581Z",
"url": "https://files.pythonhosted.org/packages/91/7a/b9c92a9d70b6f271b15295ff7ddf80533bbe28256a1de55035d3f0db4bc7/annofabapi_3dpc_extensions-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-07 09:06:33",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kurusugawa-computer",
"github_project": "annofabapi-3dpc-extensions",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "annofabapi-3dpc-extensions"
}