annofabapiの3DPC Editor用の拡張機能です。
Project description
annofabapi-3dpc-extensions
annofabapiの3DPC(3D Point Cloud) Editor用の拡張機能です。
Install
- Python 3.7+
Install
$ pip install annofabapi-3dpc-extensions
Usage
cuboidアノテーションやセグメントアノテーションに対応したデータクラスを利用できます。
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
Project details
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
Close
Hashes for annofabapi-3dpc-extensions-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 491dfdb7fa2bbb4802be9a4ca321141a17dbebd8002c51651659136f3196b244 |
|
MD5 | 0b5c4845a328c6947941f89f3d30c405 |
|
BLAKE2b-256 | e5ef608da18e024e0989c13e8bc63139ca0bca9ea08c13d38f5a16138d764282 |
Close
Hashes for annofabapi_3dpc_extensions-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa96ef9161f67334f81f6f0d0c03c4f3fbcabad90c54db2f8019980bf448a484 |
|
MD5 | 5ba9a9886891fe50a079dfad322da422 |
|
BLAKE2b-256 | 81be00ad461504da0176345644fd85da6e706d7c8696aa55f97f80b91b1996bc |