最初のシーンをアップロード
Kognicプラットフォームに生データをアップロードする際は、シーンの形式で行う必要があります。シーンとは、画像、点群、その他のセンサーデータなど、さまざまなソースからのデータの集合です。
このガイドでは、2D(カメラのみ)または3D(カメラおよびLiDAR/RADAR)で最初のシーンをアップロードする手順を説明します。
前提条件
クイックスタートクイックスタートガイドを完了し、kognic-ioライブラリをインストール済みである必要があります。複数のワークスペースにアクセスできるユーザーは、データのアップロード先となるワークスペースを指定する必要があります(高度な設定高度な設定を参照)。
コード例
2Dシーンをアップロードするには、生画像をローカルマシンに用意する(リモートデータの場合は概要コールバックを作成する)必要があります。以下の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. Build scene object
scene = Cameras(
external_id="my-first-scene",
frame=Frame(images=[Image(filename="path/to/image.jpg")])
)
# 2. Upload scene
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. Build scene object
scene = Cameras(
external_id="my-first-scene",
frame=Frame(
images=[
# Sensor names must be unique
Image(sensor_name = "CAM1", filename="path/to/image1.jpg"),
Image(sensor_name = "CAM2", filename="path/to/image2.jpg")
],
)
)
# 2. Upload scene
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. Build scene object
scene = CamerasSequence(
external_id="my-first-scene",
frames=[
# Relative timestamps must be unique and strictly increasing
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. Upload scene
client = KognicIOClient()
scene_uuid = client.cameras_sequence.create(scene).scene_uuid
print("Scene uploaded, got uuid:", scene_uuid)2D/3Dシーンをアップロードするには、生画像と点群をローカルマシンに用意する(リモートデータの場合は概要コールバックを作成する)必要があります。さらに、キャリブレーションデータも必要です。以下の3つのステップで行います:
- キャリブレーション概要キャリブレーションを作成する
- 前のステップで作成したキャリブレーションを参照して、Pythonでシーンオブジェクトを構築する
- シーンオブジェクトをKognicプラットフォームにアップロードする
以下にいくつかのケースの例を示します。
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)複数の点群もサポートされていますが、もう少し多くのデータが必要になるため、上記の例には含まれていません。詳細については、モーション補償モーション補償セクションを参照してください。
Zenseact Open Dataset(ZOD)のデータを使用してシーンをアップロードするためのサンプルコードとチュートリアルを用意しています。2D、3D、および集約3Dシーンに対応しています。ガイドドキュメントとサンプルコードについては、ZODデータのアップロードZODデータのアップロードをご覧ください。
ZODデータをダウンロード済みで、Kognic APIの認証情報をお持ちであれば、サンプルをそのまま実行して、機能するシーンを作成できます。
kognic-io>=2.5.1でサポートされています。
この機能を使用するには、データインテグレーションデータインテグレーションを設定しておく必要があります。
Kognicがサポートする形式のデータをバケットに保存しており、そのバケットに対してデータインテグレーションを設定している場合は、スクリプトでデータをダウンロードしてアップロードする代わりに、バケット内のファイルへのパスを指定してシーンを作成できます。この例は完全な2D+3Dシーンですが、点群、IMUデータ、自車両ポーズを削除することで、2Dのみのシーンに縮小できます。
この方法では、シーンタイプを指定する必要のない新しいシーンモデルを使用します。シーンタイプは画像と点群の有無から推定され、この方法で作成されたシーンは常に「シーケンス」タイプのシーンになります。
コード例と詳細については、シーンの例シーンの例を参照してください。
この方法でアップロードする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>
},
...
]