씬
이 내용은 kognic-io>2.5.0 사용자에게 적용됩니다. 이전 버전을 사용 중이라면 레거시 문서를 참고하거나 업그레이드하세요.
씬은 Kognic이 센서 리소스를 일정 기간(프레임)에 걸쳐 그룹화하는 방식입니다.
씬 모델은 SceneRequest에서 시작됩니다.
class SceneRequest:
"""A scene request is used to create a scene in the Kognic platform.
Attributes:
workspace_id (str): The ID of the workspace where the scene will be created.
external_id (str): The external ID of the scene.
frames (List[Frame]): A list of frames that make up the scene.
sensor_specification (Optional[SensorSpecification]): Sensor specification let's the user set the order and display names of the sensors.
calibration_id (Optional[Calibration]): Calibration of the scene, required if the scene contains pointclouds.
metadata (Optional[dict]): Metadata for the scene.
imudata_resource (Optional[Resource]): IMU data of the scene, required for aggregation and motion compensation.
should_motion_compensate (Optional[bool]): Whether to motion compensate the scene.
postpone_external_resource_import (Optional[bool]): Whether to postpone the import of external resources. Only available for scenes with external resources.
"""
workspace_id: str
external_id: str
frames: List[Frame]
sensor_specification: Optional[SensorSpecification] = None
calibration_id: Optional[str] = None
metadata: Optional[dict] = None
imudata_resource: Optional[Resource] = None
should_motion_compensate: Optional[bool] = None
postpone_external_resource_import: Optional[bool] = Noneworkspace id는 씬을 생성할 워크스페이스를 지정하는 데 사용됩니다. 워크스페이스에 대해서는 여기에서 더 자세히 알아볼 수 있습니다.
external id는 kognic이 생성하는 긴 UUID를 참조하지 않고도 사용자가 씬에 대해 소통할 수 있게 해줍니다. 다만 씬에 대한 작업을 수행하려면 기본 키(primary key)인 UUID가 필요합니다.
Frames는 씬에서 시간을 담는 방식이며, 각 프레임은 센서 데이터를 가진 타임스탬프에 대응합니다(IMU 데이터는 보통 훨씬 높은 빈도를 가지므로 이 센서들에 포함되지 않습니다). 프레임에 대해서는 아래에서 더 자세히 살펴봅니다.
Sensor specifications는 센서를 표시하는 방법에 대한 설정입니다. 여기에서 다양한 센서의 순서를 설정하고 사람이 읽기 좋은 표시 이름을 지정할 수 있습니다.
Calibrations은 하나 이상의 라이다 리소스가 제공될 때 사용됩니다. 캘리브레이션은 씬을 생성하기 전에 존재해야 합니다. 캘리브레이션에 대해서는 여기에서 더 자세히 알아볼 수 있습니다.
Metadata는 씬에 대한 추가 데이터를 담을 수 있는 단순한 플랫 딕셔너리입니다.
IMU data는 다중 라이다 포인트 클라우드의 모션 보상에 사용됩니다. IMU 형식은 여기에서 확인할 수 있습니다.
Should motion compensate flag는 씬을 모션 보상할지 여부를 결정하는 데 사용됩니다.
Postpone external resource import는 Kognic 플랫폼이 즉시 씬 처리를 시작하여 제공된 클라우드 리소스를 읽을지 여부를 결정합니다. 따라서 이 플래그는 외부 리소스를 사용할 때만 효과가 있습니다. true로 설정하면 씬은 인덱싱된(indexed) 상태로 생성됩니다. 인덱싱된 씬에 대해서는 여기에서 더 자세히 알아볼 수 있습니다.
Frame
frame 객체는 씬 정보의 대부분을 담고 있으며 다음과 같은 형태입니다.
class Frame:
"""A frame is a collection of images and pointcloud at a given timestamp.
Attributes:
frame_id (str): The ID of the frame.
timestamp_ns (int): The timestamp of the frame in nanoseconds.
images (List[ImageResource]): A list of images in the frame.
pointclouds (Optional[List[SensorResource]]): A list of pointclouds in the frame.
ego_vehicle_pose (Optional[EgoVehiclePose]): The pose of the ego vehicle at the time of the frame, required if providing
pointclouds.
metadata (Optional[dict]): Metadata for the frame.
"""
frame_id: str
timestamp_ns: int
images: List[ImageResource]
pointclouds: Optional[List[SensorResource]] = None
ego_vehicle_pose: Optional[EgoVehiclePose] = None
metadata: Optional[dict] = NoneResources
리소스는 모두 기본(base) 리소스의 확장입니다. 기본 리소스는 데이터를 지정하는 몇 가지 다른 방식을 제공하기 위해 존재합니다. 모델은 다음과 같은 형태입니다.
class Resource:
external_resource_uri: Optional[str]
local_file: Optional[LocalFile]
class LocalFile:
filename: str
data: Optional[bytes] = None
callback: Optional[Callback] = None리소스는 데이터 통합을 가리키는 URI인 external_resource_uri를 가지거나, 로컬 파일을 가질 수 있습니다. external_resource_uri가 동작하려면 링크에 명시된 대로 데이터 통합을 설정해야 합니다. 로컬 파일은 파일명, 바이트스트림(data), 또는 바이트 스트림을 반환하는 콜백의 세 가지 방식으로 제공할 수 있습니다. 어떤 경우든 파일명은 Kognic 플랫폼이 리소스를 식별하는 데 사용되므로 반드시 제공되어야 합니다.
인덱싱된 씬(Indexed scenes)
필요해지기 전까지 Kognic에 데이터를 업로드하지 않는 것이 유용한 경우가 있습니다. 예를 들어 매우 큰 데이터셋 중 일부만 살펴보고 싶지만 업로드 시점에는 어떤 씬을 살펴봐야 할지 모르는 경우입니다. 전체 데이터셋을 업로드하면 사용자의 클라우드에서 Kognic 클라우드로 데이터가 이동하면서 많은 양의 이그레스(egress)가 발생합니다. 따라서 씬을 지정만 해두고 필요할 때만 임포트할 수 있도록 인덱싱된 씬을 도입했습니다. 인덱싱된 씬을 사용하려면 kognic이 사용자의 클라우드에서 데이터에 접근하는 방법을 알 수 있도록 데이터 통합을 생성해야 합니다. 이를 통해 씬 명세, 어떤 리소스가 어느 프레임에 속하는지, 캘리브레이션이 있는지 등을 지정만 해두면 Kognic이 이를 저장하되 아직 리소스를 읽을 필요는 없게 됩니다. Kognic 플랫폼에서 씬으로 작업을 수행해야 할 때, 클릭이나 버튼 또는 API 호출을 통해 씬을 사용 가능하게 만들 수 있습니다. 그러면 Kognic이 사용자의 클라우드에서 리소스를 읽어 처리한 후 Kognic의 클라우드에 저장합니다.
예제
씬 생성하기
예제는 씬 예제에서 확인하세요.
씬 목록 조회하기
scene_uuids = ["cca60a67-cb68-4645-8bae-00c6e6415555", "cc8776d0-f537-4094-8b11-8c2111741e2f"]
client.scene.get_scenes_by_uuids(scene_uuids=scene_uuids)인덱싱된 씬 임포트하기
씬이 인덱싱된 상태일 때 임포트, 즉 "사용 가능하게" 만들 수 있습니다. kognic-io에는 이를 위한 메서드가 있습니다.
client.scene.import_indexed_scene("cca60a67-cb68-4645-8bae-00c6e6415555"씬 재인덱싱하기
인덱싱된 씬에 대해 더 이상 Kognic이 데이터를 저장하지 않기를 원하지만 씬 자체를 완전히 삭제하고 싶지는 않다면, 다음을 실행하여 재인덱싱, 즉 인덱싱된 상태로 되돌릴 수 있습니다.
client.scene.reindex_scene("cca60a67-cb68-4645-8bae-00c6e6415555"