첫 번째 씬 업로드하기
원시 데이터를 Kognic 플랫폼에 업로드할 때는 씬의 형태로 업로드해야 합니다. 씬은 이미지, 포인트 클라우드 및 기타 센서 데이터 등 다양한 소스에서 나온 데이터의 집합입니다.
이 가이드는 2D(카메라 전용) 또는 3D(카메라와 라이다/레이더)로 첫 번째 씬을 업로드하는 과정을 안내합니다.
사전 준비사항
Quickstart 가이드를 성공적으로 완료했고 kognic-io 라이브러리가 설치되어 있어야 합니다. 여러 워크스페이스에 접근 권한이 있는 사용자는 업로드할 워크스페이스를 지정해야 합니다.
코드 예제
2D 씬을 업로드하려면 원본 이미지가 로컬 머신에 있어야 합니다(또는 원격 데이터를 위한 콜백을 생성해야 합니다). 이는 두 단계로 진행됩니다.
- 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 씬을 업로드하려면 원본 이미지와 포인트 클라우드가 로컬 머신에 있어야 합니다(또는 원격 데이터를 위한 콜백을 생성해야 합니다). 추가로 캘리브레이션 데이터도 있어야 합니다. 이는 세 단계로 진행됩니다.
- 캘리브레이션 생성하기
- 이전 단계의 캘리브레이션을 참조하여 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)여러 개의 포인트 클라우드도 지원되지만, 조금 더 많은 데이터가 필요하므로 위 예제에는 표시되지 않았습니다. 자세한 내용은 모션 보상 섹션을 참고하세요.
2D, 3D, 집계된 3D 씬을 포함하여 Zenseact Open Dataset (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>
},
...
]