最初のシーンをアップロード
4 分
kognicプラットフォームに生データをアップロードする際は、シーンの形式で行う必要があります。シーンとは、画像、点群、その他のセンサーデータなど、さまざまなソースからのデータ の集合です。 このガイドでは、2d(カメラのみ)または3d(カメラおよびlidar/radar)で最初のシーンをアップロードする手順を説明します。 前提条件 docid\ wym9o4uavbhveiojew8ze ガイドを完了し、kognic ioライブラリがインストールされていること。複数のワークスペースにアクセスできるユーザーは、データのアップロード先となる docid\ qtir2bromdzhuva3catlg 必要があります。 コード例 2dシーンのアップロード 2dシーンをアップロードするには、ローカルマシンに生画像が利用可能であるか、リモートデータ用の docid\ m9gj 7ge3m0jf7hvlohj2 を作成する必要があります。 以下の2つのステップで行います pythonでシーンオブジェクトを構築する シーンオブジェクトをkognicプラットフォームにアップロードする 以下にいくつかのケースの例を示します。 from kognic io client import kognicioclient from kognic io model scene cameras import cameras, frame from kognic io model scene resources import image \# 1 シーンオブジェクトの構築 scene = cameras( external id="my first scene", frame=frame(images=\[image(filename="path/to/image jpg")]) ) \# 2 シーンのアップロード client = kognicioclient() scene uuid = client cameras create(scene) scene uuid print("scene uploaded, got uuid ", scene uuid)from kognic io client import kognicioclient from kognic io model scene cameras import cameras, frame from kognic io model scene resources import image \# 1 シーンオブジェクトの構築 scene = cameras( external id="my first scene", frame=frame( images=\[ \# センサー名は一意である必要があります image(sensor name = "cam1", filename="path/to/image1 jpg"), image(sensor name = "cam2", filename="path/to/image2 jpg") ], ) ) \# 2 シーンのアップロード client = kognicioclient() scene uuid = client cameras create(scene) scene uuid print("scene uploaded, got uuid ", scene uuid)from kognic io client import kognicioclient from kognic io model scene cameras sequence import camerassequence, frame from kognic io model scene resources import image \# 1 シーンオブジェクトの構築 scene = camerassequence( external id="my first scene", frames=\[ \# 相対タイムスタンプは一意かつ厳密に昇順である必要があります frame( relative timestamp=0, frame id="1", images=\[image(filename="path/to/image1 jpg")], ), frame( relative timestamp=100, frame id="2", images=\[image(filename="path/to/image2 jpg")], ), frame( relative timestamp=200, frame id="3", images=\[image(filename="path/to/image3 jpg")], ), ] ) \# 2 シーンのアップロード client = kognicioclient() scene uuid = client cameras sequence create(scene) scene uuid print("scene uploaded, got uuid ", scene uuid) 2d/3dシーンをアップロードす 2d/3dシーンをアップロードするには、ローカルマシンに生画像と点群が利用可能であるか、リモートデータ用の docid\ m9gj 7ge3m0jf7hvlohj2 を作成する必要があ さらに、キャリブレーションデータが必要です。以下の3つのステップで行います docid 40ujebw5cst4e4djxsgty を作成する 前のステップで作成したキャリブレーションを参照して、pythonでシーンオブジェクトを構築する シーンオブジェクトをkognic platformにアップロードする 以下に、いくつかの異なるケースの例を示します。 from kognic io client import kognicioclient from kognic io model calibration import sensorcalibration, pinholecalibration, lidarcalibration from kognic io model scene lidars and cameras import lidarsandcameras, frame from kognic io model scene resources import image, pointcloud client = kognicioclient() \# 1 create calibration (see calibration section for more details) sensor calibration = sensorcalibration( external id = "my first calibration", calibration = { "cam" pinholecalibration( ), "lidar" lidarcalibration( ) } ) created calibration = client calibration create calibration(sensor calibration) \# 2 build scene object scene = lidarsandcameras( external id=f"my first scene", calibration id = created calibration id, frame=frame( images=\[image(sensor name = "cam", filename="path/to/image jpg")], point clouds=\[pointcloud(sensor name = "lidar", filename="path/to/pointcloud pcd")] ) ) \# 3 upload scene scene uuid = client lidars and cameras create(scene) scene uuid print("scene uploaded, got uuid ", scene uuid)from kognic io client import kognicioclient from kognic io model calibration import sensorcalibration, pinholecalibration, lidarcalibration from kognic io model scene lidars and cameras import lidarsandcameras, frame from kognic io model scene resources import image, pointcloud client = kognicioclient() \# 1 create calibration (see calibration section for more details) sensor calibration = sensorcalibration( external id = "my first calibration", calibration = { "cam1" pinholecalibration( ), "cam2" pinholecalibration( ), "lidar" lidarcalibration( ) } ) created calibration = client calibration create calibration(sensor calibration) \# 2 build scene object scene = lidarsandcameras( external id="my first scene", calibration id = created calibration id, frame=frame( images=\[ image(sensor name = "cam1", filename="path/to/image1 jpg"), image(sensor name = "cam2", filename="path/to/image2 jpg"), ], point clouds=\[pointcloud(sensor name = "lidar", filename="path/to/pointcloud pcd")] ) ) \# 3 upload scene client = kognicioclient() scene uuid = client lidars and cameras create(scene) scene uuid print("scene uploaded, got uuid ", scene uuid)from kognic io client import kognicioclient from kognic io model calibration import sensorcalibration, pinholecalibration, lidarcalibration from kognic io model scene lidars and cameras sequence import lidarsandcamerassequence, frame from kognic io model scene resources import image, pointcloud client = kognicioclient() \# 1 create calibration (see calibration section for more details) calibration = { "cam" pinholecalibration( ), "lidar" lidarcalibration( ) } sensor calibration = sensorcalibration( external id = "my first calibration", calibration = { "cam" pinholecalibration( ), "lidar" lidarcalibration( ) } ) created calibration = client calibration create calibration(sensor calibration) \# 2 build scene object scene = lidarsandcamerassequence( external id="my first scene", calibration id = created calibration id, frames=\[ \# relative timestamps must be unique and strictly increasing frame( relative timestamp=0, frame id="1", images=\[image(sensor name = "cam", filename="path/to/image1 jpg")], point clouds=\[pointcloud(sensor name = "lidar", filename="path/to/pointcloud1 pcd")] ), frame( relative timestamp=100, frame id="2", images=\[image(sensor name = "cam", filename="path/to/image2 jpg")], point clouds=\[pointcloud(sensor name = "lidar", filename="path/to/pointcloud2 pcd")] ), frame( relative timestamp=200, frame id="3", images=\[image(sensor name = "cam", filename="path/to/image3 jpg")], point clouds=\[pointcloud(sensor name = "lidar", filename="path/to/pointcloud3 pcd")] ), ] ) \# 3 upload scene scene uuid = client lidars and cameras sequence create(scene) scene uuid print("scene uploaded, got uuid ", scene uuid) 複数の点群もサポートされていますが、追加データが必要なため、上記の例には含まれていません。詳細については、 docid unwsc cucoyh mu9josc セクションを参照してください。 zodデータを使用したアップロード https //zod zenseact com/ データを使用したシーンのアップロードに関するサンプルコードとチュートリアルを用意しています。2d、3d、および集約された3dシーンに対応しています。 docid 879aqjou83xuhogqu 0yr zodデータをダウンロード済みで、kognic apiの認証情報をお持ちであれば、サンプルをそのまま実行して機能するシーンを作成できます! 以下を使用するには、kognic ioバージョン>=2 5 1をインストールしてください。 このようにシーンを作成する際に使用するモデルとメソッドは、上記とは若干異なります。すべてのシーンはシーケンスとして扱われるため、シーンタイプごとに特定のモデルを使用する必要はありません。 バケットから2dシーンを作成する この機能を使用するには docid\ l93 pnieahqpk 6j ouef データインテグレーションを設定する必要があります。 kognicがサポートしているフォーマットのデータを、データインテグレーションを設定済みのバケット上に保存している場合、データをローカルにダウンロードしてkognicにアップロードする必要はありません。代わりに、バケット内のファイルを指定するだけで十分です。 from kognic io client import kognicioclient from kognic io model scene import scenerequest, frame, imageresource scene = scenerequest( workspace id="\<workspace id>", external id="my first scene from external resources", frames=\[ frame( frame id="1", timestamp ns=1742225790, # absolute unix timestamp of frame images=\[ imageresource( external resource uri="\<uri>", # matching your data integration, e g s3 //my bucket/some image jpg sensor name="my camera", local file=none ) ], ) ], postpone external resource import=false # set true if you want to import at a later point in time ) client = kognicioclient() scene uuid = client scene create scene(scene) scene uuid print("scene uploaded, got uuid ", scene uuid) バケットから2d/3dシーンを作成す この機能を使用するには docid\ l93 pnieahqpk 6j ouef データインテグレーションを設定する必要があります。 kognicがサポートしているフォーマットのデータを、データインテグレーションを設定済みのバケット上に保存している場合、データをローカルにダウンロードしてkognicにアップロードする必要はありません。代わりに、バケット内のファイルを指定するだけで十分です。 from kognic io client import kognicioclient from kognic io model scene import scenerequest, frame, imageresource, sensorresource, resource, egovehiclepose scene = scenerequest( workspace id="\<workspace id>", external id="my first scene from external resources", frames=\[ frame( frame id="1", timestamp ns=1742225790, pointclouds=\[ sensorresource( external resource uri="\<uri>", sensor name="my lidar", local file=none, ) ], images=\[ imageresource( external resource uri="\<uri>", sensor name="my camera", start shutter timestamp ns=1742225789, end shutter timestamp ns=1742225790, local file=none, ) ], ego vehicle pose=egovehiclepose( x=0 0, y=0 0, z=0 0, rotation x=0 0, rotation y=0 0, rotation z=0 0, rotation w=1 0 ) ) ], calibration id="\<calibration id>", imudata resource=resource( external resource uri="\<uri>", local file=none ), sensor specification=none, should motion compensate=false, postpone external resource import=false, # set true if you want to import at a later point in time ) client = kognicioclient() scene uuid = client scene create scene(scene) scene uuid print("scene uploaded, got uuid ", scene uuid) このモデルでは、imuデータのアップロードも可能です。imuデータは以下のフォーマットを含むjsonファイルとして指定します。 \[ { "postion" { "x" 0 0, "y" 0 0, "z" 0 0 }, "rotationquaternion" { "w" 0 0, "x" 0 0, "y" 0 0, "z" 0 0 } "timestamp" \<unix timestamp in nano seconds> }, ]
