mirror of
https://github.com/m5stack/StackFlow.git
synced 2026-05-20 11:32:11 -07:00
[update] llm-camera
This commit is contained in:
@@ -0,0 +1,147 @@
|
||||
# llm-camera
|
||||
视频源单元,用于从 USB V4L2 视频设备中获取视频流到内部通道。
|
||||
|
||||
## setup
|
||||
配置单元工作。
|
||||
|
||||
发送 json:
|
||||
```json
|
||||
{
|
||||
"request_id":"2",
|
||||
"work_id":"camera",
|
||||
"action":"setup",
|
||||
"object":"camera.setup",
|
||||
"data":{
|
||||
"response_format":"camera.raw",
|
||||
"input":"/dev/video0",
|
||||
"enoutput":false,
|
||||
"frame_width":320,
|
||||
"frame_height":320
|
||||
}
|
||||
}
|
||||
```
|
||||
- request_id:参考基本数据解释。
|
||||
- work_id:配置单元时,为 `camera`。
|
||||
- action:调用的方法为 `setup`。
|
||||
- object:传输的数据类型为 `camera.setup`。
|
||||
- response_format:返回结果为 `camera.raw`,是 yuv422 格式。
|
||||
- input:读取的设备名。
|
||||
- frame_width:输出的视频帧宽。
|
||||
- frame_height:输出的视频帧高。
|
||||
- enoutput:是否起用用户结果输出。
|
||||
|
||||
响应 json:
|
||||
|
||||
```json
|
||||
{
|
||||
"created":1731488402,
|
||||
"data":"None",
|
||||
"error":{
|
||||
"code":0,
|
||||
"message":""
|
||||
},
|
||||
"object":"None",
|
||||
"request_id":"2",
|
||||
"work_id":"camera.1003"
|
||||
}
|
||||
```
|
||||
- created:消息创建时间,unix 时间。
|
||||
- work_id:返回成功创建的 work_id 单元。
|
||||
|
||||
|
||||
## exit
|
||||
|
||||
单元退出。
|
||||
|
||||
发送 json:
|
||||
|
||||
```json
|
||||
{
|
||||
"request_id": "7",
|
||||
"work_id": "camera.1003",
|
||||
"action": "exit",
|
||||
}
|
||||
```
|
||||
|
||||
响应 json:
|
||||
|
||||
```json
|
||||
{
|
||||
"created":1731488402,
|
||||
"data":"None",
|
||||
"error":{
|
||||
"code":0,
|
||||
"message":""
|
||||
},
|
||||
"object":"None",
|
||||
"request_id":"7",
|
||||
"work_id":"camera.1003"
|
||||
}
|
||||
```
|
||||
|
||||
error::code 为 0 表示执行成功。
|
||||
|
||||
## taskinfo
|
||||
|
||||
获取任务列表。
|
||||
|
||||
发送 json:
|
||||
```json
|
||||
{
|
||||
"request_id": "2",
|
||||
"work_id": "camera",
|
||||
"action": "taskinfo"
|
||||
}
|
||||
```
|
||||
|
||||
响应 json:
|
||||
|
||||
```json
|
||||
{
|
||||
"created":1731652311,
|
||||
"data":["camera.1003"],
|
||||
"error":{
|
||||
"code":0,
|
||||
"message":""
|
||||
},
|
||||
"object":"camera.tasklist",
|
||||
"request_id":"2",
|
||||
"work_id":"camera"
|
||||
}
|
||||
```
|
||||
|
||||
获取任务运行参数。
|
||||
|
||||
发送 json:
|
||||
```json
|
||||
{
|
||||
"request_id": "2",
|
||||
"work_id": "camera.1003",
|
||||
"action": "taskinfo"
|
||||
}
|
||||
```
|
||||
|
||||
响应 json:
|
||||
|
||||
```json
|
||||
{
|
||||
"created":1731652344,
|
||||
"data":{
|
||||
"enoutput":false,
|
||||
"response_format":"camera.raw",
|
||||
"input":"/dev/video0",
|
||||
"frame_width":320,
|
||||
"frame_height":320
|
||||
},
|
||||
"error":{
|
||||
"code":0,
|
||||
"message":""
|
||||
},
|
||||
"object":"camera.taskinfo",
|
||||
"request_id":"2",
|
||||
"work_id":"camera.1003"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
> **注意:work_id 是按照单元的初始化注册顺序增加的,并不是固定的索引值。**
|
||||
@@ -37,7 +37,6 @@ private:
|
||||
|
||||
public:
|
||||
std::string response_format_;
|
||||
std::vector<std::string> inputs_;
|
||||
task_callback_t out_callback_;
|
||||
bool enoutput_;
|
||||
bool enstream_;
|
||||
@@ -95,19 +94,10 @@ public:
|
||||
try {
|
||||
response_format_ = config_body.at("response_format");
|
||||
enoutput_ = config_body.at("enoutput");
|
||||
devname_ = config_body.at("devname");
|
||||
devname_ = config_body.at("input");
|
||||
frame_width_ = config_body.at("frame_width");
|
||||
frame_height_ = config_body.at("frame_height");
|
||||
|
||||
if (config_body.contains("input")) {
|
||||
if (config_body["input"].is_string()) {
|
||||
inputs_.push_back(config_body["input"].get<std::string>());
|
||||
} else if (config_body["input"].is_array()) {
|
||||
for (auto _in : config_body["input"]) {
|
||||
inputs_.push_back(_in.get<std::string>());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (...) {
|
||||
return true;
|
||||
}
|
||||
@@ -263,7 +253,9 @@ public:
|
||||
auto llm_task_obj = llm_task_[work_id_num];
|
||||
req_body["response_format"] = llm_task_obj->response_format_;
|
||||
req_body["enoutput"] = llm_task_obj->enoutput_;
|
||||
req_body["inputs"] = llm_task_obj->inputs_;
|
||||
req_body["input"] = llm_task_obj->devname_;
|
||||
req_body["frame_width"] = llm_task_obj->frame_width_;
|
||||
req_body["frame_height"] = llm_task_obj->frame_height_;
|
||||
send("camera.taskinfo", req_body, LLM_NO_ERROR, work_id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user