云台服务接口
介绍
云台服务接口:提供摄像头云台的角度控制和图像采集功能。
| 功能 | Python |
|---|---|
| 获取云台状态 | ✔ |
| 设置云台角度 | ✔ |
| 拍摄图片 | ✔ |
| 获取已保存图片列表 | ✔ |
云台控制
Python接口
get_ptzf(timeout=5)
功能说明
获取当前云台的 Pan(水平转动)、Tilt(垂直倾斜)、Zoom(变焦)、Focus(对焦)值。
参数说明
| 参数名 | 类型 | 必填/默认值 | 说明 |
|---|---|---|---|
timeout | int | 默认: 5 | 服务调用超时时间(秒)。 |
返回值
| 类型 | 说明 |
|---|---|
GetCurrentPTZFResponse | state.code == 0 表示成功;通过 response.pan、response.tilt、response.zoom、response.focus 访问各轴值。 |
调用示例
python
from daystar_api.lowlevel_skills import get_ptzf
response = get_ptzf()
if response.state.code == 0:
print(f"Pan: {response.response.pan}°")
print(f"Tilt: {response.response.tilt}°")
print(f"Zoom: {response.response.zoom}")set_ptzf(pan=0.0, tilt=0.0, zoom=1.0, focus=0, relative=False, timeout=30)
功能说明
设置云台的 Pan、Tilt、Zoom、Focus 值。支持绝对定位和相对移动两种模式。
参数说明
| 参数名 | 类型 | 必填/默认值 | 说明 |
|---|---|---|---|
pan | float | 默认: 0.0 | 水平转动角度(度)。 |
tilt | float | 默认: 0.0 | 垂直倾斜角度(度)。 |
zoom | float | 默认: 1.0 | 变焦值。 |
focus | int | 默认: 0 | 对焦值。 |
relative | bool | 默认: False | True 时为相对当前位置的增量;False 时为绝对角度。 |
timeout | int | 默认: 30 | 服务调用超时时间(秒)。 |
返回值
| 类型 | 说明 |
|---|---|
SetPTZFServiceResponse | state.code == 0 表示成功。 |
调用示例
python
from daystar_api.lowlevel_skills import set_ptzf
# 绝对定位
set_ptzf(pan=45.0, tilt=-30.0, zoom=2.0)
# 相对移动(在当前位置基础上偏转)
set_ptzf(pan=10.0, tilt=5.0, relative=True)
# 归零
set_ptzf(pan=0.0, tilt=0.0, zoom=1.0)图像采集
Python接口
capture_image(image_name, type='rgb', timeout=5)
功能说明
从摄像头拍摄并保存图像。图像保存在 /root/data/daystar_api/images/ 目录下。
参数说明
| 参数名 | 类型 | 必填/默认值 | 说明 |
|---|---|---|---|
image_name | str | 必填 | 图像保存名称(不含扩展名)。 |
type | str | 默认: 'rgb' | 图像类型:'rgb' 彩色图像;'infra' 红外图像。 |
timeout | int | 默认: 5 | 服务调用超时时间(秒)。 |
返回值
| 类型 | 说明 |
|---|---|
CaptureImageResponse | state.code == 0 表示成功;response.success 为布尔值;response.message 包含保存路径信息。 |
调用示例
python
from daystar_api.lowlevel_skills import capture_image
# 拍摄彩色图像
response = capture_image("photo_001")
if response.response.success:
print(f"图像已保存: {response.response.message}")
# 拍摄红外图像
capture_image("infra_001", type="infra")get_available_images(timeout=5)
功能说明
获取已保存的所有图像名称列表。图像存储在 /root/data/daystar_api/images/。
参数说明
| 参数名 | 类型 | 必填/默认值 | 说明 |
|---|---|---|---|
timeout | int | 默认: 5 | 服务调用超时时间(秒)。 |
返回值
| 类型 | 说明 |
|---|---|
GetAvailableImagesResponse | state.code == 0 表示成功;response.image_names 为图像名称列表。 |
调用示例
python
from daystar_api.lowlevel_skills import get_available_images
response = get_available_images()
if response.response.success:
for img_name in response.response.image_names:
print(f"图像: {img_name}")