# 配置

> **Deprecation Notice**
> 本页描述的功能已在 Luxonis Hub 中移除或替换。功能可能受限，仅 Hub Original 客户可用。请参考最新指南来配置设备、管理设备群组并部署应用程序。

感知应用程序通过名为 robotapp.toml 的 [TOML 文件](https://toml.io/en/) 进行配置。该文件位于应用程序的根目录中。以下是一个示例：

```toml
config_version = "2.0"

[info]
name = "{{{ APP_NAME }}}"
description = "This is a generated description. Replace it with your own."

[runtime]
application = "app.py#Application"
workdir = "/app"

[runtime.runs_on]
type = "image"
name = "ghcr.io/luxonis/robothub-app-v2:2023.326.2033-rvc2-regular"

[[configuration]]
visual = "section"
title = "Upload intervals"

[[configuration]]
key = "image_event_upload_interval_minutes"
label = "Image event upload interval (minutes)"
field = "num_range"
step = 1
min = 1
max = 60
initial_value = 1
```

## 参考

### 根字段

config_version 配置文件的格式版本。目前仅支持的版本为 2.0。

### 信息

info 部分包含应用程序的信息，例如名称和描述。

| 字段 | 描述 |
| --- | --- |
| `info.name` | 应用程序的名称。当前未使用。 |
| `info.description` | 应用程序的描述。当前未使用。 |

### 运行时

runtime 部分配置应用程序的运行时环境。

| 字段 | 描述 |
| --- | --- |
| `runtime.application` | 包含应用程序主要逻辑的 Python 文件名。路径相对于根目录。 |
| `runtime.workdir` | 应用程序的工作目录。默认为 `/app`。 |
| `runtime.permissions` | 运行应用程序所需的权限。默认为 `[]`。示例：`permissions = ["gpio", "i2c"] ` |
| `runtime.runs_on` | 应用程序将在其中运行的运行时容器。`type = "image"`应用程序将在基于指定镜像的容器中运行。在安装前会拉取该镜像。示例：`[runtime.runs_on] type = "image" name =
"ghcr.io/luxonis/robothub-app-v2:2023.326.2033-rvc2-regular" ` |

### 配置

configuration 部分定义应用程序的安装时配置。

视觉元素

| 类型 | 描述 |
| --- | --- |
| `divider` | 用于配置部分的分隔线。示例：`[[configuration]] visual = "divider" ` |
| `section` | 用于配置部分的章节。示例：`[[configuration]] visual = "section" title = "Upload intervals" ` |

字段

| 类型 | 描述 |
| --- | --- |
| `boolean` | 布尔类型字段。示例：`[[configuration]] field = "boolean" key = "my_boolean" label = "Enable feature" initial_value = true ` |
| `num_range` | 数值范围字段。示例：`[[configuration]] field = "num_range" key = "my_num_range" label = "Range" step = 1 min = 0 max = 100
initial_value = 50 ` |
| `choice` | 选择字段。示例：`[[configuration]] field = "choice" key = "my_choice" label = "Choose option" style = "radio" # ir "dropdown"
allow_multiple = false options = [ { key = "option1", label = "Option 1", default = true }, { key = "option2", label = "Option 2"
} ] ` |
| `text` | 文本字段。示例：`[[configuration]] field = "text" key = "my_text" label = "Text input" prefix = "USD" initial_value = "Example"
` |
| `time_range` | 时间范围字段。示例：`[[configuration]] field = "time_range" key = "my_time_range" label = "Time range" initial_value = {
from = "08:00", to = "18:00" } ` |
| `roi_rect4_selector` | 直播流上的 ROI 选择器字段。 由两个点 (x0, y0) 和 (x1, y1) 定义。示例：`[[configuration]] field = "roi_rect4_selector" key =
"my_roi_rect4_selector" label = "Detection area" initial_value = "0,0,1,1" ` |
| `roi_rect8_selector` | 直播流上的 ROI 选择器字段。 由四个点 (x0, y0)、(x1, y1)、(x2, y2)、(x3, y3) 定义。示例：`[[configuration]] field =
"roi_rect8_selector" key = "my_roi_rect8_selector" label = "Detection area" initial_value = "0,0;1,0;0,1;1,1" ` |
