工程指南
本页面向实施与集成工程师,覆盖面单字段提取方案从模型启用、Agent 配置、仪表板与 Webhook 接入到提示词定制与日常运维的完整过程。方案定位与业务价值见 方案说明。
1. 方案场景
核心动作:把面单放进相机视野,等字段自动入库。
| 场景 | 采集对象 | 典型用途 |
|---|---|---|
| 快递驿站 / 仓储出入库 | 面单 | 运单号、承运商、重量自动入库 |
| 财务 / 客服 | 面单、回执 | 收件人、联系电话检索与对账 |
| 任何"图片 → 结构化字段"录入 | 各类单据 | 替代人工看图录入 |
不适用的场景:需要面单全文文字与文字框坐标(用文档识别方案的 PP-OCR 流水线,与本方案互补);版面极端混乱且要求字段 100% 准确(小参数量视觉模型存在字段级误差,需保留人工复核通道)。
识别范围:样例配置的 12 个字段(可自定义)
样例配置抽取以下 12 个面单字段(以验证用 DPD 面单为例;字段清单可自定义,调整方法见 5.3),每个字段写回一个设备虚拟指标 virtual.ocr.<字段名>:
| 字段 | 虚拟指标 | 含义 | 样例面单参考值 |
|---|---|---|---|
| tracking_no | virtual.ocr.tracking_no | 运单号(条码旁的 4 段数字) | 1550 1804 9197 451 |
| reference | virtual.ocr.reference | 参考号(Ref 行,通常 8 位) | 10448206 |
| carrier | virtual.ocr.carrier | 承运商品牌 | DPD |
| service | virtual.ocr.service | 服务类型 | NEXT DAY SERVICE |
| weight | virtual.ocr.weight | 总重量 | 10 kg |
| postcode | virtual.ocr.postcode | 邮编 | GB-NN11 8LR |
| ship_date | virtual.ocr.ship_date | 发货日期时间 | 21/08/19 04:10 |
| receiver_name | virtual.ocr.receiver_name | 收件人名称 | Amazon Fulfillment Center |
| receiver_address | virtual.ocr.receiver_address | 收件人完整地址(合并为单行) | Unit A Daventry Distribution Center, Yoyal Oak Way N, Daventry, United Kingdom |
| contact_name | virtual.ocr.contact_name | Contact 块联系人/公司 | DPD GROUP LTD |
| contact_address | virtual.ocr.contact_address | Contact 块地址 | Roebuck Lane, BIRMINGHAM, B66 1BY |
| contact_phone | virtual.ocr.contact_phone | Contact 块电话 | 0121 500 2500 |
字段在当前面单上不可见时,该字段写 null 或跳过。要增删字段、换一类单据,改提示词与字段清单即可(见 5.3)。
2. 方案组成(BOM)
| # | 组成 | 型号 / 规格 | 数量 | 用途 |
|---|---|---|---|---|
| 1 | NE302 相机 | 38 × 38 mm 迷你 AI 相机,白光补光 LED | 每点位 1 台 | 面单抓拍、图像上报 |
| 2 | 方案固件 | NE302 Docsnap 分支固件(下载固件包 ne302_App_signed_*_pkg.bin) + DocAligner 模型包(下载),升级步骤见文档识别方案 4.1 | 1 套 | 端侧单据检出,"放入即拍" |
| 3 | NeoMind 主机 | NG4500 AI Box / 服务器 / 个人电脑,预留 GPU 显存运行 MiniCPM-V-4.7-1B(内置模型目录) | 1 套 | 设备接入、Agent 识别、字段写回、仪表板、Webhook |
面单识别由 NeoMind 主机上的视觉语言模型完成,相机端无需额外模型;DocAligner 模型包仅负责端侧"放入即拍"的检出触发。
3. 组网拓扑
通用要求:
- 相机与 NeoMind 主机之间 MQTT 可达;Broker 用 NeoMind 内置服务即可(设备"数据传输"页配置)
- 图像大于 1 MiB 时设备自动分片上报,平台自动重组,无需额外配置
- NeoMind 主机 GPU 显存需容纳视觉模型(可与主引擎共存;显存被挤占会导致识别服务停止,见第 6 节)
4. 方案搭建
按以下顺序完成 6 步,对应小节 4.1–4.6:
- 确认 MiniCPM 视觉模型已启用
- 接入 NE302 设备
- 创建面单识别 Agent
- 验证识别与写回
- 配置仪表板字段卡片
- 配置 Webhook 推送
说明:本节的工具策略、提示词、12 个字段清单、仪表板卡片与 Webhook 订阅,均针对本方案验证用的 DPD 测试面单,是一份"样例配置"——复制搭建时,请按你要识别的单据类型与业务字段调整提示词与字段清单(方法见 5.3),其余步骤不变。
4.1 确认 MiniCPM 视觉模型已启用
- 平台右上角 Settings(设置)→ LLM Backends:当前启用的内置模型以卡片显示,确认出现 MiniCPM-V-4.7-1B(验证环境中它作为 Vision companion 与主引擎共存,由 llama.cpp CUDA 运行时承载)
- 若未启用:点 Switch Model,在内置模型目录中选择 MiniCPM 视觉模型——首次选择自动下载,无需 API Key、完全离线
- 启用后,该模型即出现在 AI Agent 编辑页的 Model 下拉中
关于 MiniCPM:MiniCPM 是 OpenBMB(面壁智能与清华大学共同建设的开源组织)开源的端侧大模型系列,主打"小参数量、高性能";MiniCPM-V 是其中的多模态分支,官方定位强调图像文字识别(OCR)与文档理解能力,适合在边缘设备与本地服务器上运行。NeoMind 内置目录中的 MiniCPM-V-4.7-1B 即来自该系列——在本方案中经 llama.cpp 运行时于 NeoMind 主机本地推理,不需要任何 API Key。开源仓库:OpenBMB/MiniCPM

Settings → LLM Backends:MiniCPM-V-4.7-1B 作为视觉伴随模型运行(llama.cpp CUDA 运行时),Agent 的 Model 下拉即可选择
4.2 接入 NE302 设备
与文档识别方案的设备接入完全相同:相机"数据传输"页指向 NeoMind 主机(内置 Broker,端口 1883),平台侧添加 ne302_camera 类型设备,设备 ID 与相机一致。完成后放一份面单,设备详情页应出现 image_data 指标更新。
4.3 创建面单识别 Agent
平台左侧 AI Agents → Create AI Agent,按表单三段依次配置:
左侧栏 · 基本信息:
- Name:如
NE302-OCR - Model:下拉选择 MiniCPM-V-4.7-1B(带 Vision 标记)
1. Mission & Data Sources(任务与数据源):
- Mission(提示词):粘贴本节末尾的面单抽取提示词,并把写回命令中的设备 ID
20006C替换为你的设备 ID - Sources → Add Data Source:添加设备 NE302 的
image_data指标(读取策略 Any · Report stale)
2. Actions & Output(动作与输出):
- Model tools:选 Scoped allowlist,工具勾选 shell——Agent 靠它把字段写回设备
- JSON fields:开启,逐条添加 12 个字段(字段名 + 描述,描述会注入提示词辅助识别,见下方字段清单)
- Publish as platform data sources:保持关闭(字段经 write-metric 落到设备指标;Agent 的 ai: 数据源不被仪表板组件渲染)
3. Schedule, Guardrails & Notifications(触发与防护):
- 触发方式选 Event,事件源设备勾选 NE302(image_data 更新即触发)
- Failure breaker:
3(连续失败自动熔断) - Notify:按需开启 On failure(执行失败通知)
点 Save agent 保存;可用 Dry run 在不落配置的情况下先试跑一次。

Edit Agent 表单(两段拼接,重复的字段清单只保留一处):上段——Model 选 MiniCPM-V-4.7-1B,Model tools 选 Scoped allowlist 并勾选 shell,JSON fields 开启并定义 12 个字段;下段——触发方式 Event,事件源勾选 NE302,Failure breaker 为 3,Notify 按需开启
提示词全文(复制到 Mission,替换设备 ID;提示词针对验证用 DPD 面单样例,字段与自查规则按你要识别的单据调整,见 5.3):
You are a parcel waybill information extraction engine. Extract every specified field from the waybill image reported by the device.
Requirements:
1. Search each field actively. Pay special attention to the Contact block (contact name, address, phone), Total Weight, and package count.
2. For the reference field, take the number on the same line as the Ref label or on the immediately following line. It is usually 8 digits and must NOT be a tracking number.
3. Field values must use the literal text printed in the image. If a field is not visible, return null for it.
4. Output JSON only, with exactly the specified keys.
MANDATORY self-check. Before producing the final JSON, verify each of these and fix the value if it fails:
- tracking_no: the Track number is printed as 4 groups of 4 digits (e.g. 1550 1804 9197 451), usually right above or below the barcode. Take ONLY those 4 groups. Never append the Ref number. Never repeat groups. Never drop the leading group.
- reference: must be the short number on the Ref line (usually 8 digits). Never a tracking number. Never 13+ digits.
- contact_name: must be the carrier company printed inside the Contact block (e.g. DPD GROUP LTD). Never the receiver name (e.g. Amazon).
- contact_address: must be the street/city/postcode lines inside the Contact block (e.g. Roebuck Lane, BIRMINGHAM, B66 1BY). Never the receiver address. Never placeholder digits such as 0000000000 or 3000000000.
- contact_phone: must be the real phone printed after Phone in the Contact block (e.g. 0121 500 2500). Never placeholder digits such as 00000000.
- receiver_address: must be the FULL multi-line address of the receiver/consignee, joined into one line with a comma and space. Never truncate it to a single word.
AFTER you finish extracting, persist EVERY non-null field to the device by calling the shell tool once per field. The command form is:
neomind device write-metric 20006C --metric virtual.ocr.<NAME> --value '<VALUE>'
CRITICAL quoting rule: wrap the value in SINGLE quotes so that spaces are preserved. The value itself must NOT contain any quotes inside.
Correct: --value 'DPD'
Correct: --value 'Unit A Daventry Distribution Center, Yoyal Oak Way N, Daventry, United Kingdom'
WRONG: --value '"DPD"'
WRONG: --value Unit A Daventry Distribution Center (unquoted: gets truncated at the first space)
Write these 12 metrics, one shell call each (skip any field whose value is null):
virtual.ocr.tracking_no, virtual.ocr.reference, virtual.ocr.carrier, virtual.ocr.service, virtual.ocr.weight, virtual.ocr.postcode, virtual.ocr.ship_date, virtual.ocr.receiver_name, virtual.ocr.receiver_address, virtual.ocr.contact_name, virtual.ocr.contact_address, virtual.ocr.contact_phone
Rules for the shell calls:
- Keep each value on ONE line. Replace any newline inside a value with a comma and space.
- Always wrap the value in single quotes.
- If a value itself contains a single quote, replace that inner quote with a space.
- Do not stop until all non-null fields have been written.
提示词三条硬规则(改动提示词时勿删):① 逐字段调用
neomind device write-metric <设备ID> --metric virtual.ocr.<字段> --value '<值>'写回;② 值必须单引号包裹——含空格的值不加引号会被截断成首字母;③ 值内不含任何引号,换行替换为"逗号 + 空格"。
JSON fields 字段清单(样例字段;字段名 + 描述,描述为英文原文、注入提示词):
| 字段名 | 描述 |
|---|---|
| tracking_no | Full tracking number next to the Track label, all 4 digit groups complete including any leading group, e.g. 1550 1804 9197 451 |
| reference | Number on the same line as the Ref label or on the immediately following line (usually 8 digits, e.g. 10448206) |
| carrier | Carrier brand name, e.g. DPD |
| service | Service type, e.g. NEXT DAY SERVICE |
| weight | Total weight shown next to Total Weight, e.g. 10 kg |
| postcode | Postcode, e.g. GB-NN11 8LR |
| ship_date | Ship date and time, e.g. 21/08/19 04:10 |
| receiver_name | Receiver name, the first line of the upper block on the waybill, e.g. Amazon Fulfillment Center |
| receiver_address | Full receiver address including every street line and the city, postcode and country, joined with commas, e.g. Unit A Daventry Distribution Center, Yoyal Oak Way N, Daventry, United Kingdom |
| contact_name | Contact person or company name in the Contact block, e.g. DPD GROUP LTD |
| contact_address | Full address in the Contact block, including street, city and postcode, e.g. Roebuck Lane, BIRMINGHAM, B66 1BY |
| contact_phone | Phone number following Phone in the Contact block, e.g. 0121 500 2500 |
4.4 验证识别与写回
- 放一份面单进相机视野(或设备详情 Command Control → Capture 手动抓拍一次)
- AI Agents → 打开该 Agent → History:应出现新执行,工具调用为连续 12 次 shell
- 设备详情 → Real-time Metrics:
virtual.ocr.*系列指标出现并带 Virtual 标记,值为最新识别结果

Agent 详情页 Overview:执行统计(103 次执行、平均 28 s)与最近一次运行的 12 个输出字段值

设备详情页:12 个 virtual.ocr. 字段(带 Virtual 标记)与 image_data、端侧检出结果并列展示*
4.5 配置仪表板字段卡片
- Visual Dashboard → New Dashboard,命名如
NE302-Waybill-OCR - 从组件库添加 12 个数值卡片,数据源分别绑定设备 NE302 的
virtual.ocr.*指标(类型选设备指标,读取模式 latest;卡片与样例字段一一对应,字段清单调整后随之增减) - 绑定注意:数据源必须选设备指标——Agent 的
ai:数据源后端有值,但前端组件不渲染,绑了会显示空白 - 保存后放入一份面单:卡片值随每次抓拍自动刷新
4.6 配置 Webhook 推送
- Data Explorer → Data Push → Create Target
- Target Type 选 Webhook,填写业务系统的 Webhook URL;Schedule 选 Event-driven;数据范围填来源模式——逐字段订阅则列出各字段,如
device:<设备ID>:virtual.ocr.carrier、device:<设备ID>:virtual.ocr.tracking_no等 - 按需配置重试与批处理(样例:重试 3 次、指数退避);保存并启动
- 放入一份面单,业务端应收到形如下方的推送(每个订阅字段各推一条):
{
"source_id": "device:20006C:virtual.ocr.carrier",
"value": "DPD",
"timestamp": 1796127154
}
推送状态与投递日志在 Data Push 目标列表查看。

Data Explorer → Data Push:ne302-ocr-webhook-test 目标 Running,Event-driven,订阅 virtual.ocr. 字段*
4.7 端到端联调
四点验证全部通过,点位交付即完成:
- 执行触发:放面单 → AI Agents 的 History 出现新执行,工具调用 12 次 shell
- 字段写回:设备详情
virtual.ocr.*12 项更新 - 仪表板刷新:12 张卡片显示最新字段值
- 推送到达:业务 Webhook 收到各字段推送
5. 数据对接
5.1 字段口径
- 每个字段一条虚拟指标,字符串类型;值为面单上的字面文本,长地址合并为单行(逗号 + 空格)
- 字段在当前面单上不可见时,识别结果中记 null 且不写回——设备上对应指标将保持上一次抓拍的值;下游应以指标时间戳与抓拍时间比对判断新旧,不要把"指标有值"当作"本次面单含该字段"
- 识别精度以现场实测为准:密集数字区(分段运单号)是小参数量视觉模型的已知弱项,关键字段建议业务侧保留人工复核
5.2 Webhook 消费建议
- 每个订阅字段各推一条,
source_id标明来源字段(如device:20006C:virtual.ocr.carrier),按其分流入库 - 同一次抓拍会触发多条推送,业务侧按
source_id+timestamp去重 - 需要一次收全单次抓拍的字段时,把订阅模式放宽为
device:<设备ID>:virtual.ocr.*——一次抓拍会推送多条(逐字段),业务侧按timestamp将同批推送聚合为一条记录
5.3 提示词定制指南
- 增删字段:两处同步改——Mission 末尾的 write-metric 指标清单 + Actions & Output 的 JSON fields 字段清单(名称与描述)
- 换单据类型:重写抽取规则与自查规则;描述里给"正确值 / 错误值"的对照例子最有效
- 值格式三条规则(单引号包裹、值内无引号、单行)已在提示词中,勿删——删掉后含空格的值会被截断成首字母
6. 日常运维
| 现象 / 任务 | 处置 |
|---|---|
| 仪表板卡片空白 | 卡片数据源必须是设备指标;绑成 Agent 的 ai: 数据源前端不渲染 |
| 字段值只剩首字母 | 写回命令的值没用单引号包裹(含空格被截断);核对提示词引号规则是否被改动 |
| 字段值带多余引号 | 模型在值外多写了一层引号;确认提示词"值内不含引号"规则还在,并重新执行一次 |
| Agent 不触发 | Edit Agent → 第 3 段确认触发方式为 Event、事件源勾选了对应设备;连续失败会触发 Failure breaker 熔断——先排查并解决失败原因(见上行),再恢复 Agent 执行 |
| 识别超时 / 执行失败 | Settings → LLM Backends 确认模型 Running;显存被其他任务挤占会使服务停止,预留显存后重新激活 |
| tracking_no 漏段 / 串行 | 密集数字区是小参数量视觉模型已知弱项:改善拍摄角度与补光,或强化提示词中该字段的自查描述;仍不达标时评估更大参数量模型 |
| 字段持续为 null | 该字段在当前面单上不可见属正常;持续为 null 检查拍摄距离与面单在画面中的占比 |
| 想换字段 / 换单据 | 见 5.3 提示词定制指南 |
7. 性能与规格
| 指标 | 数值 |
|---|---|
| 输入图像 | NE302 抓拍原图(1280 × 720 JPEG) |
| 识别模型 | MiniCPM-V-4.7-1B(内置视觉模型,llama.cpp CUDA 运行时,本地推理,无需 API Key) |
| 单次执行耗时 | 实测平均约 28 s(12 字段抽取 + 12 次写回;以现场实测为准) |
| 执行成功率 | 验证环境 98%(103 次执行,101 成功) |
| 字段级精度 | 多数字段稳定;密集数字区(分段运单号)有已知误差,以现场实测为准 |
| 触发方式 | 事件驱动(image_data 更新);支持 Dry run 手动试跑 |
| 数据留存 | 字段虚拟指标入设备时序库,留存周期随平台数据管理设置 |
8. 技术支持
- 社区支持:Discord / GitHub Discussions
- 方案定制与批量部署:联系我们,请注明点位规模与现有业务系统对接方式