# 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 배포에서 지원됨 |
| ------------------------------------------------------------------------------------------------------------ | -------------------- |
| <p>객체 탐지:</p><ul><li>Roboflow에서 학습된 YOLOv8 모델, Fast와 Accurate 모두</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: (중심),
        #        y:(중심),
        #        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)를 호스트 디바이스로 사용했을 때의 추론 속도(밀리초 기준)는 평균 약 15ms, 즉 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: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
