> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/roboflow/roboflow-jp/deploy/sdks/luxonis-oak.md).

# Luxonis OAK

この [Luxonis OAK (OpenCV AI Kit)](https://shop.luxonis.com/) は、組み込みコンピュータビジョンシステムのデプロイに広く使われているエッジデバイスです。

OAKデバイスは、下流アプリケーションの動作を担うホストマシンと組み合わせて使用します。参考として、こちらをご覧ください [Luxonisのユースケース](https://docs.luxonis.com/en/latest/#example-use-cases) と [Roboflowのケーススタディ](https://blog.roboflow.com/tag/case-studies/).

**ちなみに：** まだOAKデバイスをお持ちでない場合は、 [Roboflow Storeから購入できます](https://store.roboflow.com/) 。10%割引になります。

### タスクサポート

以下のタスクタイプはホスト型APIでサポートされています：

| タスクタイプ                                                                                                                          | Luxonis OAK Deploymentでサポート |
| ------------------------------------------------------------------------------------------------------------------------------- | --------------------------- |
| <p>物体検出：</p><ul><li>Roboflowで学習されたYOLOv8モデル（すべてのサイズ：Nano、Small、Medium、Large、X Large）</li><li>Roboflowで学習されたYOLOv11モデル</li></ul> | ✅                           |
| 分類                                                                                                                              |                             |
| インスタンスセグメンテーション                                                                                                                 |                             |
| セマンティックセグメンテーション                                                                                                                |                             |

### Luxonis OAKにモデルをデプロイ

#### サポートされるLuxonisデバイスとホスト要件

Roboflow Inference Serverは以下のデバイスをサポートしています：

* OAK-D
* OAK-D-Lite
* OAK-D-POE
* OAK-1（深度なし）

#### インストール

以下をインストールします： `roboflowoak`, `depthai`、および `opencv-python` パッケージ：

```python
pip install roboflowoak
pip install depthai
pip install opencv-python
```

これで、 `roboflowoak` パッケージを使って、カスタム学習済みのRoboflowモデルを実行できます。

#### 推論の実行：デプロイ

Depth機能のないOAKデバイスにデプロイする場合は、 `depth=False` を、 `rf` オブジェクトをインスタンス化（作成）するときに設定してください。Depth搭載のOAKにはモデル名の末尾に「D」が付きます。つまりOAK-DとOAK-D-Liteです。

また、次の行はコメントアウトしてください `max_depth = np.amax(depth)` と `cv2.imshow("depth", depth/max_depth)`

```python
from roboflowoak import RoboflowOak
import cv2
import time
import numpy as np

if __name__ == '__main__':
    # RoboflowOakモジュールでオブジェクト（rf）をインスタンス化
    rf = RoboflowOak(model="YOUR-MODEL-ID", confidence=0.05, overlap=0.5,
    version="YOUR-MODEL-VERSION-#", api_key="YOUR-PRIVATE_API_KEY", rgb=True,
    depth=True, device=None, blocking=True)
    # モデルを実行し、検出結果付きのビデオ出力を表示
    while True:
        t0 = time.time()
        # rf.detect() 関数がモデル推論を実行します
        result, frame, raw_frame, depth = rf.detect()
        predictions = result["predictions"]
        #{
        #    predictions:
        #    [ {
        #        x: (middle),
        #        y:(middle),
        #        width:
        #        height:
        #        depth: ###->
        #        confidence:
        #        class:
        #        mask: {
        #    ]
        #}
        #frame - 前処理後のフレーム、予測結果付き
        #raw_frame - OAKから取得した元のフレーム
        #depth - raw_frame用の深度マップ。中央カメラに対して中央整列済み
        
        # timing: ベンチマーク目的
        t = time.time()-t0
        print("FPS ", 1/t)
        print("PREDICTIONS ", [p.json() for p in predictions])

        # 深度計算のためのパラメータを設定
        # DepthのないOAKを使用している場合は、以下の2行をコメントアウトしてください
        max_depth = np.amax(depth)
        cv2.imshow("depth", depth/max_depth)
        # ビデオフィードを連続フレームとして表示
        cv2.imshow("frame", frame)
    
        # OAK推論ウィンドウを閉じる／推論を停止するには：CTRL+q または CTRL+c
        if cv2.waitKey(1) == ord('q'):
            break
```

以下のコードを入力してください（プレースホルダーテキストをPythonスクリプトへのパスに置き換えた後）

```python
# ウィンドウを閉じるには（中断または推論終了）、キーボードでCTRL+cを入力してください
python3 /path/to/[YOUR-PYTHON-FILE].py
```

Apple Macbook Air（M1）をホストデバイスにした場合の推論速度（ミリ秒）は、平均約15 ms、つまり66 FPSでした。 ***注**：OAKで使用するホストデバイスはFPSに大きく影響します。システムを作成する際はこれを考慮してください。*

#### トラブルシューティング

OAKデバイスのセットアップで問題が発生している場合は、Luxonisのインストール手順を確認し、RGBの例を [Luxonisのインストール](https://docs.luxonis.com/en/latest/#demo-script)で正常に実行できることを確認してください。 [Roboflow Forum](https://discuss.roboflow.com/).

### 関連情報

* [Luxonis OAKのステップバイステップセットアップガイド](https://blog.roboflow.com/opencv-ai-kit-deployment/)
* [M1チップ使用時のインストール問題 · Issue #299 · luxonis/depthai · GitHub](https://github.com/luxonis/depthai/issues/299) （depthai SDK）


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.roboflow.com/roboflow/roboflow-jp/deploy/sdks/luxonis-oak.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
