InferenceHandler
safety.engine.api.InferenceHandler
NPU edge 추론 기반으로 Safety 기능을 수행하는 InferenceHandler class 입니다.
Usage
demo/inference.py 참고
build(config)
classmethod
InferenceHandler instance를 생성합니다.
Parameters:
Returns:
| Name | Type | Description |
|---|---|---|
InferenceHandler |
InferenceHandler
|
build가 완료된 instance. |
Note
default_alarm_options, default_object_options는 API에서 기본적으로 비활성화합니다 (enabled=False).
infer(images, camera_ids, timestamps)
현재 설정된 inference 옵션을 바탕으로 inference를 수행합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images
|
list[ndarray]
|
inference를 수행할 BGR uint8 image list (shape: [H, W, 3]) |
required |
camera_ids
|
list[int]
|
images의 각 image에 대한 camera_id list |
required |
timestamps
|
list[int]
|
images의 각 image에 대한 timestamp list (단위: 밀리초) |
required |
Returns:
Raises:
| Type | Description |
|---|---|
InvalidNumberOfInputsError
|
images, camera_ids, timestamps의 길이가 서로 다를 때 |
UnregisteredCameraIdError
|
등록되지 않은 camera_id가 포함된 경우 |
InvalidTimestampError
|
timestamp가 음수이거나 같은 camera_id에 대해 중복일 때 |
register_camera(camera_id)
검사할 camera_id를 등록합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
camera_id
|
int
|
등록할 camera_id |
required |
Raises:
| Type | Description |
|---|---|
InvalidCameraIdError
|
camera_id가 비음수 int가 아닐 때 |
AlreadyRegisteredCameraIdError
|
이미 등록된 camera_id일 때 |
release_camera(camera_id)
등록된 camera_id를 해제합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
camera_id
|
int
|
해제할 camera_id |
required |
Raises:
| Type | Description |
|---|---|
UnregisteredCameraIdError
|
등록되지 않은 camera_id일 때 |
get_registered_camera_ids()
get_default_tracker_option(camera_id)
기본 tracker option을 반환합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
camera_id
|
int
|
사용하지 않음, API 일관성을 위해 존재. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: tracker option |
get_tracker_option(camera_id)
등록된 camera_id에 대한 tracker option을 반환합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
camera_id
|
int
|
tracker option을 반환할 camera_id |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: tracker option |
Raises:
| Type | Description |
|---|---|
UnregisteredCameraIdError
|
등록되지 않은 camera_id일 때 |
set_tracker_option(camera_id, tracker_option)
등록된 camera_id에 대한 tracker option을 설정합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
camera_id
|
int
|
tracker option을 설정할 camera_id |
required |
tracker_option
|
dict[str, Any]
|
tracker option |
required |
Raises:
| Type | Description |
|---|---|
UnregisteredCameraIdError
|
등록되지 않은 camera_id일 때 |
get_default_object_options(camera_id)
기본 object options을 반환합니다 (enabled=False 강제).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
camera_id
|
int
|
사용하지 않음, API 일관성을 위해 존재. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, dict]
|
dict[str, dict]: 각 object class별 default option dict |
get_object_options(camera_id)
등록된 camera_id에 대한 object options을 반환합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
camera_id
|
int
|
object options을 반환할 camera_id |
required |
Returns:
| Type | Description |
|---|---|
dict[str, dict]
|
dict[str, dict]: object options |
Raises:
| Type | Description |
|---|---|
UnregisteredCameraIdError
|
등록되지 않은 camera_id일 때 |
set_object_options(camera_id, object_options)
등록된 camera_id에 대한 object options을 설정합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
camera_id
|
int
|
object options을 설정할 camera_id |
required |
object_options
|
dict[str, dict]
|
object options |
required |
Raises:
| Type | Description |
|---|---|
UnregisteredCameraIdError
|
등록되지 않은 camera_id일 때 |
get_default_event_options(camera_id)
기본 event options을 반환합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
camera_id
|
int
|
사용하지 않음, API 일관성을 위해 존재. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, dict]
|
dict[str, dict]: API event type을 key로 하는 default event options |
get_event_options(camera_id)
등록된 camera_id에 대한 event options을 반환합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
camera_id
|
int
|
event options을 반환할 camera_id |
required |
Returns:
| Type | Description |
|---|---|
dict[str, dict]
|
dict[str, dict]: API event type을 key로 하는 event options |
Raises:
| Type | Description |
|---|---|
UnregisteredCameraIdError
|
등록되지 않은 camera_id일 때 |
set_event_options(camera_id, event_options)
등록된 camera_id에 대한 event options을 설정합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
camera_id
|
int
|
event options을 설정할 camera_id |
required |
event_options
|
dict[str, dict]
|
API event type을 key로 하는 event options |
required |
Raises:
| Type | Description |
|---|---|
UnregisteredCameraIdError
|
등록되지 않은 camera_id일 때 |
get_default_alarm_options(camera_id)
기본 alarm options을 반환합니다 (enabled=False 강제).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
camera_id
|
int
|
사용하지 않음, API 일관성을 위해 존재. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, dict]
|
dict[str, dict]: API event type을 key로 하는 default alarm options |
get_alarm_options(camera_id)
등록된 camera_id에 대한 alarm options을 반환합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
camera_id
|
int
|
alarm options을 반환할 camera_id |
required |
Returns:
| Type | Description |
|---|---|
dict[str, dict]
|
dict[str, dict]: API event type을 key로 하는 alarm options |
Raises:
| Type | Description |
|---|---|
UnregisteredCameraIdError
|
등록되지 않은 camera_id일 때 |
set_alarm_options(camera_id, alarm_options)
등록된 camera_id에 대한 alarm options을 설정합니다.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
camera_id
|
int
|
alarm options을 설정할 camera_id |
required |
alarm_options
|
dict[str, dict]
|
API event type을 key로 하는 alarm options |
required |
Raises:
| Type | Description |
|---|---|
UnregisteredCameraIdError
|
등록되지 않은 camera_id일 때 |