reCamera Intellisense
Requirements
- -
python3 (no external packages) - Reachable reCamera HTTP API (default port
80) - Credentials stored in
~/.recamera/devices.json (created automatically; declared in skill metadata)
Security considerations
- - Credential storage: Device tokens are stored in
~/.recamera/devices.json. Protect this file with appropriate permissions (chmod 600) and do not place unrelated secrets there. - Plain HTTP transport: Communication to devices uses HTTP (port 80) by default — data including images and tokens travels unencrypted. Configure HTTPS on your devices if operating on untrusted networks.
- Trusted networks only: The skill polls devices and downloads snapshot/image files. Only use it with cameras on networks you trust.
- Camera-specific tokens: Use dedicated per-camera tokens (
sk_xxx). Do not reuse tokens shared with cloud services. - Source review: The bundle includes full Python sources under
scripts/. Review them to verify behavior matches your expectations before granting autonomous execution.
Scripts
All scripts live under {baseDir}/scripts and accept one JSON object as CLI argument (optional for detect_local_device and list_devices).
- -
device_manager.py: add/update/remove/list/get device credentials, file download detection_manager.py: models, schedule, rules, events, event-image fetchcapture_manager.py: capture status/start/stop, one-shot image capture
Full API signatures and CLI schemas: See REFERENCE.md
Agent rules
- 1. Always pass complete JSON; never use interactive prompts.
- Use exactly one of
device_name (preferred) or inline device. - Auth token format:
sk_xxx (from Web Console → Device Info → Connection Settings → HTTP/HTTPS Settings). - To detect by label name: call
get_detection_models_info, map name → label index, use index in label_filter. - Poll
get_detection_events every 1–10s; pass start_unix_ms for incremental reads. - Prefer event metadata first; fetch images only when needed.
- CLI output: success = JSON on stdout (mutating commands may produce no stdout, check exit code
0); failure = actionable stderr. On error, surface stderr and provide one concrete fix.
Execution checklist
Copy and track for multi-step tasks:
CODEBLOCK0
CLI quickstart
Run from {baseDir}:
CODEBLOCK1
Python pattern (long-running automation)
CODEBLOCK2
Use a loop with checkpointed start_unix_ms for incremental polling.
Workflows
Onboard a device
- 1.
add_device with host + token. - INLINECODE24 to verify.
Configure object detection by name
- 1.
get_detection_models_info → map object name to label index. - INLINECODE26 .
- INLINECODE27 with
label_filter containing the index. - INLINECODE29 to start fresh.
Monitor events
- 1. Poll
get_detection_events with start_unix_ms every 1–10s. - Track last timestamp for next poll.
- Fetch images only when needed via
fetch_detection_event_image.
On-demand snapshot
- - CLI:
capture_image with local_save_path → returns {capture, saved_path, bytes}. - Python:
capture_image → persist returned content bytes. - Alternative:
fetch_detection_event_image with local_save_path.
Troubleshooting
| Symptom | Fix |
|---|
| 401/403 auth error | Re-copy token from Web Console |
| Timeout / connection refused |
Verify host, network path, device power |
| Schedule rejected | Use
Day HH:MM:SS format |
| Empty rules or events | Enable rule/storage prerequisites; check region filter; poll more frequently |
| Image fetch failed | Use fresh
snapshot_path; data may rotate out |
| Import errors in Python mode | Run from
{baseDir}; append
./scripts to
sys.path |
reCamera Intellisense
要求
- - python3(无需外部包)
- 可访问的 reCamera HTTP API(默认端口 80)
- 凭据存储在 ~/.recamera/devices.json 中(自动创建;在技能元数据中声明)
安全注意事项
- - 凭据存储:设备令牌存储在 ~/.recamera/devices.json 中。请使用适当的权限保护此文件(chmod 600),不要将无关的机密信息放在其中。
- 纯 HTTP 传输:默认情况下,与设备的通信使用 HTTP(端口 80)——包括图像和令牌在内的数据以未加密方式传输。如果在不受信任的网络上操作,请在设备上配置 HTTPS。
- 仅限受信任网络:该技能会轮询设备并下载快照/图像文件。仅在与您信任的网络上的摄像头一起使用。
- 摄像头专用令牌:使用每个摄像头专用的令牌(sk_xxx)。不要重复使用与云服务共享的令牌。
- 源代码审查:该捆绑包包含 scripts/ 下的完整 Python 源代码。在授予自动执行权限之前,请审查它们以验证行为是否符合您的预期。
脚本
所有脚本位于 {baseDir}/scripts 下,并接受一个 JSON 对象作为 CLI 参数(detectlocaldevice 和 list_devices 可选)。
- - devicemanager.py:添加/更新/删除/列出/获取设备凭据,文件下载
- detectionmanager.py:模型、计划、规则、事件、事件图像获取
- capture_manager.py:捕获状态/开始/停止,单次图像捕获
完整 API 签名和 CLI 模式:请参阅 REFERENCE.md
代理规则
- 1. 始终传递完整的 JSON;不要使用交互式提示。
- 仅使用 devicename(首选)或内联 device 中的一个。
- 认证令牌格式:skxxx(来自 Web 控制台 → 设备信息 → 连接设置 → HTTP/HTTPS 设置)。
- 按标签名称检测:调用 getdetectionmodelsinfo,将名称映射到标签索引,在 labelfilter 中使用索引。
- 每 1-10 秒轮询 getdetectionevents;传递 startunixms 进行增量读取。
- 优先使用事件元数据;仅在需要时获取图像。
- CLI 输出:成功 = stdout 上的 JSON(变更命令可能不产生 stdout,检查退出代码 0);失败 = 可操作的 stderr。出错时,显示 stderr 并提供一条具体的修复建议。
执行清单
复制并跟踪多步骤任务:
text
reCamera 任务进度
- - [ ] 解析设备(devicename 或内联 device)
- [ ] 验证 JSON 参数
- [ ] 运行 CLI 命令
- [ ] 如果轮询,记录 startunix_ms 检查点
- [ ] 处理错误并提供一条修复建议
CLI 快速入门
从 {baseDir} 运行:
bash
python3 scripts/devicemanager.py adddevice {name:cam1,host:192.168.1.100,token:sk_xxxxxxxx}
python3 scripts/devicemanager.py listdevices
python3 scripts/detectionmanager.py getdetectionmodelsinfo {device_name:cam1}
python3 scripts/detectionmanager.py setdetectionmodel {devicename:cam1,model_id:0}
python3 scripts/detectionmanager.py getdetectionevents {devicename:cam1}
python3 scripts/detectionmanager.py cleardetectionevents {devicename:cam1}
python3 scripts/detectionmanager.py fetchdetectioneventimage {devicename:cam1,snapshotpath:/mnt/.../event.jpg,localsavepath:./event.jpg}
python3 scripts/capturemanager.py captureimage {devicename:cam1,localsave_path:./capture.jpg}
Python 模式(长时间运行的自动化)
python
from datetime import datetime, timezone
import sys
sys.path.append(./scripts)
from devicemanager import getdevice
from detectionmanager import getdetection_events
device = get_device(cam1)
events = getdetectionevents(device, startunixms=int(datetime.now(timezone.utc).timestamp() * 1000))
使用带有检查点 startunixms 的循环进行增量轮询。
工作流程
接入设备
- 1. 使用主机和令牌 adddevice。
- 使用 listdevices 进行验证。
按名称配置对象检测
- 1. getdetectionmodelsinfo → 将对象名称映射到标签索引。
- setdetectionmodel。
- 使用包含索引的 labelfilter 设置 setdetectionrules。
- cleardetectionevents 以全新开始。
监控事件
- 1. 每 1-10 秒使用 startunixms 轮询 getdetectionevents。
- 跟踪最后一次时间戳用于下一次轮询。
- 仅在需要时通过 fetchdetectionevent_image 获取图像。
按需快照
- - CLI:使用 localsavepath 的 captureimage → 返回 {capture, savedpath, bytes}。
- Python:captureimage → 持久化返回的 content 字节。
- 替代方案:使用 localsavepath 的 fetchdetectioneventimage。
故障排除
| 症状 | 修复 |
|---|
| 401/403 认证错误 | 从 Web 控制台重新复制令牌 |
| 超时/连接拒绝 |
验证主机、网络路径、设备电源 |
| 计划被拒绝 | 使用 Day HH:MM:SS 格式 |
| 规则或事件为空 | 启用规则/存储前提条件;检查区域过滤器;提高轮询频率 |
| 图像获取失败 | 使用新的 snapshot_path;数据可能已轮换出去 |
| Python 模式下的导入错误 | 从 {baseDir} 运行;将 ./scripts 添加到 sys.path |