---
title: 集約LiDARとカメラシーケンス
slug: api-guide/ja/l_Ti-lidar
docTags: 
createdAt: 2024-12-16T14:22:23.077Z
---

:::hint{type="info"}
**集約はタスク定義/アノテーション指示に移行されます**。

Kognic IO v2.9.0以降、集約シーンのサポートが変更されます。

アノテーション指示（旧タスク定義）では、シーン自体が集約LiDARとカメラシーケンスでなくても、集約ビューを使用したアノテーションを要求できるようになりました。

このようなケースでは、標準のLiDARとカメラシーケンスシーンを使用できるようにしたため、以下に記載されている*集約*LiDARとカメラシーケンスシーンを個別に作成する必要がなくなりました。

このアプローチにより、1つのLiDARとカメラシーケンスシーンを、集約またはシーケンシャルのセットアップを組み合わせて、オプションで異なるプレアノテーションを使用しながら、複数回アノテーションすることが可能になります。

この作業方法の詳細については、Kognicまでお問い合わせください。
:::

`AggregatedLidarsAndCamerasSeq`シーンは、カメラ画像とLiDAR点群のシーケンスで構成され、各フレームには1〜20枚のカメラ画像と1〜20個の点群が含まれます（点群を事前に集約している場合、最初のフレームに1〜20個の点群が含まれ、その他のフレームには点群が0個になります）。`AggregatedLidarsAndCamerasSeq`が`LidarsAndCamerasSeq`と異なる点は、アノテーション中に点群が時間的に集約され、最初のフレームの座標系における1つの大きな点群が生成されることです。そのため、このタイプのシーンでは自車両モーションデータが**必須**です。`AggregatedLidarsAndCamerasSeq`オブジェクトの各フィールドの詳細については、シーンの[概要](docId\:M9gJ_7GE3M0jf7hvLohJ2)の関連セクションをご覧ください。

使用する座標系の詳細については、[座標系](docId:3jKwDhQCmVNvBuZboUZMr)を参照してください。

```python
from __future__ import absolute_import

from datetime import datetime
from typing import Optional
from uuid import uuid4

import kognic.io.model.scene.aggregated_lidars_and_cameras_seq as ALCSM
from examples.calibration.calibration import create_sensor_calibration
from kognic.io.client import KognicIOClient
from kognic.io.logger import setup_logging
from kognic.io.model import CreateSceneResponse, EgoVehiclePose, Image, PointCloud, Position, RotationQuaternion


def run(client: KognicIOClient, dryrun: bool = True, **kwargs) -> Optional[CreateSceneResponse]:
    print("Creating Lidar and Camera Sequence Scene...")

    lidar_sensor1 = "lidar"
    cam_sensor1 = "RFC01"
    cam_sensor2 = "RFC02"
    metadata = {"location-lat": 27.986065, "location-long": 86.922623, "vehicle_id": "abg"}

    # Create calibration
    # (Please refer to the API documentation about calibration for more details)
    calibration_spec = create_sensor_calibration(
        f"Collection {datetime.now()}",
        [lidar_sensor1],
        [cam_sensor1, cam_sensor2],
    )
    created_calibration = client.calibration.create_calibration(calibration_spec)

    scene = ALCSM.AggregatedLidarsAndCamerasSequence(
        external_id=f"Aggregated-LCS-full-example-{uuid4()}",
        frames=[
            ALCSM.Frame(
                frame_id="1",
                relative_timestamp=0,
                point_clouds=[
                    PointCloud(
                        filename="./examples/resources/point_cloud_RFL01.las",
                        sensor_name=lidar_sensor1,
                    ),
                ],
                images=[
                    Image(
                        filename="./examples/resources/img_RFC01.jpg",
                        sensor_name=cam_sensor1,
                    ),
                    Image(
                        filename="./examples/resources/img_RFC02.jpg",
                        sensor_name=cam_sensor2,
                    ),
                ],
                metadata={"dut_status": "active"},
                ego_vehicle_pose=EgoVehiclePose(
                    position=Position(x=1.0, y=1.0, z=1.0),
                    rotation=RotationQuaternion(w=0.01, x=1.01, y=1.01, z=1.01),
                ),
            ),
            ALCSM.Frame(
                frame_id="2",
                relative_timestamp=500,
                point_clouds=[
                    PointCloud(
                        filename="./examples/resources/point_cloud_RFL02.las",
                        sensor_name=lidar_sensor1,
                    ),
                ],
                images=[
                    Image(
                        filename="./examples/resources/img_RFC11.jpg",
                        sensor_name=cam_sensor1,
                    ),
                    Image(
                        filename="./examples/resources/img_RFC12.jpg",
                        sensor_name=cam_sensor2,
                    ),
                ],
                ego_vehicle_pose=EgoVehiclePose(
                    position=Position(x=2.0, y=2.0, z=2.0),
                    rotation=RotationQuaternion(w=0.01, x=2.01, y=2.01, z=2.01),
                ),
            ),
            ALCSM.Frame(
                frame_id="3",
                relative_timestamp=1000,
                point_clouds=[
                    PointCloud(
                        filename="./examples/resources/point_cloud_RFL02.csv",
                        sensor_name=lidar_sensor1,
                    ),
                ],
                images=[
                    Image(
                        filename="./examples/resources/img_RFC11.jpg",
                        sensor_name=cam_sensor1,
                    ),
                    Image(
                        filename="./examples/resources/img_RFC12.jpg",
                        sensor_name=cam_sensor2,
                    ),
                ],
                ego_vehicle_pose=EgoVehiclePose(
                    position=Position(x=3.0, y=3.0, z=3.0),
                    rotation=RotationQuaternion(w=0.01, x=2.01, y=2.01, z=2.01),
                ),
            ),
        ],
        calibration_id=created_calibration.id,
        metadata=metadata,
    )
    # Create scene
    return client.aggregated_lidars_and_cameras_seq.create(scene, dryrun=dryrun, **kwargs)


if __name__ == "__main__":
    setup_logging(level="INFO")
    client = KognicIOClient()

    # Project - Available via `client.project.get_projects()`
    project = "<project-identifier>"

    run(client, project=project)
```

:::hint{type="success"}
### dryrunを使用してシーンを検証する

メソッド呼び出しで`dryrun`パラメータをtrueに設定すると、APIを使用してシーンが検証されますが、実際には作成されません。
:::

:::hint{type="success"}
### キャリブレーションの再利用

可能であれば、同じキャリブレーションを複数のシーンで再利用でき、また再利用すべきです。
:::
