アノテーションZIPの中身の確認

アノテーションZIPをダウンロードして、前のステップで作成したアノテーションがどのようなフォーマットで格納されているのか確認しましょう。

アノテーションZIPのダウンロード

アノテーション一覧画面に遷移して、アノテーションZIPをダウンロードしてください。

📘

現在のアノテーションをすぐにアノテーションZIPに反映させたい場合は、モーダルダイアログ上の「現在のデータで手動更新」ボタンを押して、更新処理が完了したらダウンロードしてください。

アノテーションZIPの中身の確認

ダウンロードしたアノテーションZIPの中の002/002-0.jsonを開いてください。以下のような内容が記載されています。

{ "project_id": "efd75c7e-ccab-4946-9613-1cd021f1d441", "annotation_format_version": "1.2.0", "task_id": "002", "task_phase": "acceptance", "task_phase_stage": 1, "task_status": "break", "input_data_id": "002-0", "input_data_name": "002-0.bin", "details": [ { "label": "Road", "annotation_id": "01GGFH564X4P1PQ3GRDRKSFY3V", "data": { "data": "./002-0/01GGFH564X4P1PQ3GRDRKSFY3V", "_type": "Unknown" }, "attributes": {} }, { "label": "Building", "annotation_id": "01GGFH564X1M48ZNP3QDBRQPE9", "data": { "data": "./002-0/01GGFH564X1M48ZNP3QDBRQPE9", "_type": "Unknown" }, "attributes": {} }, { "label": "Motorcycle", "annotation_id": "01GGFYK59KA131WZ9K2SRMSVRQ", "data": { "data": "./002-0/01GGFYK59KA131WZ9K2SRMSVRQ", "_type": "Unknown" }, "attributes": {} }, { "label": "Car", "annotation_id": "01GGKGX8K1YQ2S8FSD9KG1KZNT", "data": { "data": "{\"kind\":\"CUBOID\",\"shape\":{\"dimensions\":{\"width\":2.3923352451056736,\"height\":1.5576410740613937,\"depth\":5.159757984979564},\"location\":{\"x\":-0.31926004953130416,\"y\":13.089790351791807,\"z\":0.7149539962410927},\"rotation\":{\"x\":0,\"y\":0,\"z\":4.71238898038469},\"direction\":{\"front\":{\"x\":-2.220446049250313e-16,\"y\":-1,\"z\":0},\"up\":{\"x\":0,\"y\":0,\"z\":1}}},\"version\":\"2\"}", "_type": "Unknown" }, "attributes": { "tracking_id": "01GGKGX8K1YQ2S8FSD9KG1KZNT", "object_motion": "" } }, { "label": "Car", "annotation_id": "01GGKXSPMF506WVAHK71729SAV", "data": { "data": "{\"kind\":\"CUBOID\",\"shape\":{\"dimensions\":{\"width\":4.762252403259278,\"height\":1.772197728327867,\"depth\":2.1422104315982184},\"location\":{\"x\":2.975333628427282,\"y\":13.303794384002686,\"z\":0.8035944064517601},\"rotation\":{\"x\":0,\"y\":0,\"z\":0},\"direction\":{\"front\":{\"x\":1,\"y\":0,\"z\":0},\"up\":{\"x\":0,\"y\":0,\"z\":1}}},\"version\":\"2\"}", "_type": "Unknown" }, "attributes": { "tracking_id": "01GGKXSPMF506WVAHK71729SAV", "object_motion": "" } } ], "updated_datetime": "2022-10-31T01:17:00.71+09:00" }

detailsキー配下を確認してください。3次元アノテーションは、アノテーションの種類に関わらずdata._typeUnknownです。data.dataの中身は、アノテーションの種類によって変わります。

  • インスタンスセグメント/セマンティックセグメント:セグメント情報が格納されたファイルへのパス
  • バウンディングボックス:バウンディングボックスの情報が記載されたJSON文字列

セグメント情報が格納されたファイル

002/002-0/フォルダ配下のファイルを、エディタで開いてください。pointsキーは、セグメントに含まれている点の情報です。番号は、アノテーション対象の点群の0始まりのインデックスを表しています。データ構造の詳細はSegmentLabelObjectDataV1を参照してください。

{ "kind": "SEGMENT", "points": [ 130439, 130442, ..., ], "version": "1" }

バウンディングボックスの情報

002/002-0.jsonの中のバウンディングボックスをJSONにデコードすると、以下のような形式になります。

{ "kind": "CUBOID", "shape": { "dimensions": { "width": 2.3923352451056736, "height": 1.5576410740613937, "depth": 5.159757984979564 }, "location": { "x": -0.31926004953130416, "y": 13.089790351791807, "z": 0.7149539962410927 }, "rotation": { "x": 0, "y": 0, "z": 4.71238898038469 }, "direction": { "front": { "x": -2.220446049250313e-16, "y": -1, "z": 0 }, "up": { "x": 0, "y": 0, "z": 1 } } }, "version": "2" }

shapeキーにバウンディングボックスの情報が格納されています。詳細はCuboidLabelObjectDataV2を参照してください。

  • dimensions:バウンディングボックスのサイズ(幅、高さ、奥行き)
  • location:バウンディングボックスの中心の位置
  • rotation:バウンディングボックスの回転
  • direction:バウンディングボックスの前側と上側の向き(回転から求められる情報)

SDKでアノテーションZIPを読み込む

annofabapi-3dpc-extensionsというannofab-api-python-clientの拡張ライブラリを利用すると、3次元アノテーションに対応したデータクラスを利用できます。また、オイラー角からクォータニオンに変換する関数など、座標変換用の関数も利用できます。

from annofabapi.parser import SimpleAnnotationZipParser from annofab_3dpc.annotation import convert_annotation_detail_data with zipfile.ZipFile("annotation.zip", "r") as zip_file: parser = SimpleAnnotationZipParser(zip_file, "002/002-0.json") result = parser.parse(convert_annotation_detail_data) car_annotation_data = result.details[3].data print(type(car_annotation_data)) # => CuboidAnnotationDetailDataV2 # バウンディングボックスのサイズを出力 print(car_annotation_data.shape.dimensions) # => Size(width=2.3923352451056736, height=1.5576410740613937, depth=5.159757984979564) # バウンディングボックスの回転のクォータニオンを出力 print(car_annotation_data.shape.rotation.to_quaternion()) # => [-0.7071067811865475, 0.0, -0.0, 0.7071067811865476]

Did this page help you?