# 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.8+
# 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.8",
"maintainer_email": null,
"keywords": null,
"author": "Kurusugawa Computer Inc.",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/d8/db/420929a66b1e5caf951ef59f60c9f71709edb39a06598e2a8c12fbf52d5c/annofabapi_3dpc_extensions-0.2.2.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.8+\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.2.2",
"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": "f4f2334328734d658cad1220128fdfa045608d3abab538ed200f878fbba2c466",
"md5": "081c97ce51bb4cab65a7b878ff4e524b",
"sha256": "5fd889fbe7e569f693beab25896679f8e004cd4d6b929a1c10114a44697c4221"
},
"downloads": -1,
"filename": "annofabapi_3dpc_extensions-0.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "081c97ce51bb4cab65a7b878ff4e524b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 7295,
"upload_time": "2024-04-03T08:41:15",
"upload_time_iso_8601": "2024-04-03T08:41:15.997692Z",
"url": "https://files.pythonhosted.org/packages/f4/f2/334328734d658cad1220128fdfa045608d3abab538ed200f878fbba2c466/annofabapi_3dpc_extensions-0.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d8db420929a66b1e5caf951ef59f60c9f71709edb39a06598e2a8c12fbf52d5c",
"md5": "182352e49c5e8aa77a640e3119429394",
"sha256": "a67d445fc141a98a1f136a31054ec900dffb6a95a4773c3b15e0dde804188bc4"
},
"downloads": -1,
"filename": "annofabapi_3dpc_extensions-0.2.2.tar.gz",
"has_sig": false,
"md5_digest": "182352e49c5e8aa77a640e3119429394",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 7521,
"upload_time": "2024-04-03T08:41:17",
"upload_time_iso_8601": "2024-04-03T08:41:17.030474Z",
"url": "https://files.pythonhosted.org/packages/d8/db/420929a66b1e5caf951ef59f60c9f71709edb39a06598e2a8c12fbf52d5c/annofabapi_3dpc_extensions-0.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-03 08:41:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kurusugawa-computer",
"github_project": "annofabapi-3dpc-extensions",
"travis_ci": true,
"coveralls": false,
"github_actions": true,
"lcname": "annofabapi-3dpc-extensions"
}