Skip to content

Commit 23d2adc

Browse files
committed
[update] llm-camera
1 parent aea8f17 commit 23d2adc

2 files changed

Lines changed: 151 additions & 12 deletions

File tree

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# llm-camera
2+
视频源单元,用于从 USB V4L2 视频设备中获取视频流到内部通道。
3+
4+
## setup
5+
配置单元工作。
6+
7+
发送 json:
8+
```json
9+
{
10+
"request_id":"2",
11+
"work_id":"camera",
12+
"action":"setup",
13+
"object":"camera.setup",
14+
"data":{
15+
"response_format":"camera.raw",
16+
"input":"/dev/video0",
17+
"enoutput":false,
18+
"frame_width":320,
19+
"frame_height":320
20+
}
21+
}
22+
```
23+
- request_id:参考基本数据解释。
24+
- work_id:配置单元时,为 `camera`
25+
- action:调用的方法为 `setup`
26+
- object:传输的数据类型为 `camera.setup`
27+
- response_format:返回结果为 `camera.raw`,是 yuv422 格式。
28+
- input:读取的设备名。
29+
- frame_width:输出的视频帧宽。
30+
- frame_height:输出的视频帧高。
31+
- enoutput:是否起用用户结果输出。
32+
33+
响应 json:
34+
35+
```json
36+
{
37+
"created":1731488402,
38+
"data":"None",
39+
"error":{
40+
"code":0,
41+
"message":""
42+
},
43+
"object":"None",
44+
"request_id":"2",
45+
"work_id":"camera.1003"
46+
}
47+
```
48+
- created:消息创建时间,unix 时间。
49+
- work_id:返回成功创建的 work_id 单元。
50+
51+
52+
## exit
53+
54+
单元退出。
55+
56+
发送 json:
57+
58+
```json
59+
{
60+
"request_id": "7",
61+
"work_id": "camera.1003",
62+
"action": "exit",
63+
}
64+
```
65+
66+
响应 json:
67+
68+
```json
69+
{
70+
"created":1731488402,
71+
"data":"None",
72+
"error":{
73+
"code":0,
74+
"message":""
75+
},
76+
"object":"None",
77+
"request_id":"7",
78+
"work_id":"camera.1003"
79+
}
80+
```
81+
82+
error::code 为 0 表示执行成功。
83+
84+
## taskinfo
85+
86+
获取任务列表。
87+
88+
发送 json:
89+
```json
90+
{
91+
"request_id": "2",
92+
"work_id": "camera",
93+
"action": "taskinfo"
94+
}
95+
```
96+
97+
响应 json:
98+
99+
```json
100+
{
101+
"created":1731652311,
102+
"data":["camera.1003"],
103+
"error":{
104+
"code":0,
105+
"message":""
106+
},
107+
"object":"camera.tasklist",
108+
"request_id":"2",
109+
"work_id":"camera"
110+
}
111+
```
112+
113+
获取任务运行参数。
114+
115+
发送 json:
116+
```json
117+
{
118+
"request_id": "2",
119+
"work_id": "camera.1003",
120+
"action": "taskinfo"
121+
}
122+
```
123+
124+
响应 json:
125+
126+
```json
127+
{
128+
"created":1731652344,
129+
"data":{
130+
"enoutput":false,
131+
"response_format":"camera.raw",
132+
"input":"/dev/video0",
133+
"frame_width":320,
134+
"frame_height":320
135+
},
136+
"error":{
137+
"code":0,
138+
"message":""
139+
},
140+
"object":"camera.taskinfo",
141+
"request_id":"2",
142+
"work_id":"camera.1003"
143+
}
144+
```
145+
146+
147+
> **注意:work_id 是按照单元的初始化注册顺序增加的,并不是固定的索引值。**

projects/llm_framework/main_camera/src/main.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class llm_task {
3737

3838
public:
3939
std::string response_format_;
40-
std::vector<std::string> inputs_;
4140
task_callback_t out_callback_;
4241
bool enoutput_;
4342
bool enstream_;
@@ -95,19 +94,10 @@ class llm_task {
9594
try {
9695
response_format_ = config_body.at("response_format");
9796
enoutput_ = config_body.at("enoutput");
98-
devname_ = config_body.at("devname");
97+
devname_ = config_body.at("input");
9998
frame_width_ = config_body.at("frame_width");
10099
frame_height_ = config_body.at("frame_height");
101100

102-
if (config_body.contains("input")) {
103-
if (config_body["input"].is_string()) {
104-
inputs_.push_back(config_body["input"].get<std::string>());
105-
} else if (config_body["input"].is_array()) {
106-
for (auto _in : config_body["input"]) {
107-
inputs_.push_back(_in.get<std::string>());
108-
}
109-
}
110-
}
111101
} catch (...) {
112102
return true;
113103
}
@@ -263,7 +253,9 @@ class llm_camera : public StackFlow {
263253
auto llm_task_obj = llm_task_[work_id_num];
264254
req_body["response_format"] = llm_task_obj->response_format_;
265255
req_body["enoutput"] = llm_task_obj->enoutput_;
266-
req_body["inputs"] = llm_task_obj->inputs_;
256+
req_body["input"] = llm_task_obj->devname_;
257+
req_body["frame_width"] = llm_task_obj->frame_width_;
258+
req_body["frame_height"] = llm_task_obj->frame_height_;
267259
send("camera.taskinfo", req_body, LLM_NO_ERROR, work_id);
268260
}
269261
}

0 commit comments

Comments
 (0)