---
title: LiDARとカメラ
slug: api-guide/ja/t-nZ-lidar
docTags: 
createdAt: 2024-12-16T14:16:02.563Z
---

:::hint{type="info"}
kognic-io 2.5.0以降、シーンタイプ（`LidarsAndCameras`）を公開せず、単一のモデルからあらゆるシーンを簡単に作成できる新しいシーンモデルを推奨しています。可能であれば新しいモデルへの移行をお勧めしますが、新しいモデルでは単一フレームのシーケンスが作成されるため、`LidarsAndCameras`シーンを必要とする既存のリクエストとは互換性がない場合があることにご注意ください。
:::

`LidarsAndCameras`は、1〜20枚のカメラ画像と1〜20個の点群を含む*単一*フレームで構成されます。`LidarsAndCameras`オブジェクトの各フィールドの詳細については、シーンの[概要](docId\:M9gJ_7GE3M0jf7hvLohJ2)の関連セクションをご覧ください。

```python
from __future__ import absolute_import

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

import kognic.io.model.scene.lidars_and_cameras as LCM
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, Image, PointCloud


def run(client: KognicIOClient, dryrun: bool = True, **kwargs) -> Optional[CreateSceneResponse]:
    print("Creating Lidars And Cameras 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 = LCM.LidarsAndCameras(
        external_id=f"lidars-and-cameras-example-{uuid4()}",
        frame=LCM.Frame(
            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,
                ),
            ],
        ),
        calibration_id=created_calibration.id,
        metadata=metadata,
    )

    # Create scene
    return client.lidars_and_cameras.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を使用してシーンが検証されますが、実際には作成されません。
:::
