ex
Fork of mbed-os-example-mbed5-blinky by
dumi_doc-master/doc/directives/ImageRecognizer.md@44:c1d8923072ba, 2017-07-18 (annotated)
- Committer:
- TMBOY
- Date:
- Tue Jul 18 16:27:22 2017 +0800
- Revision:
- 44:c1d8923072ba
?
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| TMBOY | 44:c1d8923072ba | 1 | # ImageRecognizer |
| TMBOY | 44:c1d8923072ba | 2 | |
| TMBOY | 44:c1d8923072ba | 3 | |
| TMBOY | 44:c1d8923072ba | 4 | ## Table of Contents |
| TMBOY | 44:c1d8923072ba | 5 | |
| TMBOY | 44:c1d8923072ba | 6 | |
| TMBOY | 44:c1d8923072ba | 7 | * [ImageRecognizer](#imagerecognizer) |
| TMBOY | 44:c1d8923072ba | 8 | * [Table of Contents](#table-of-contents) |
| TMBOY | 44:c1d8923072ba | 9 | * [总体逻辑](#总体逻辑) |
| TMBOY | 44:c1d8923072ba | 10 | * [ImageRecognizer.StartRecognize指令](#imagerecognizerstartrecognize指令) |
| TMBOY | 44:c1d8923072ba | 11 | * [ImageRecognizer.Recognize 事件](#imagerecognizerrecognize-事件) |
| TMBOY | 44:c1d8923072ba | 12 | |
| TMBOY | 44:c1d8923072ba | 13 | |
| TMBOY | 44:c1d8923072ba | 14 | ## 总体逻辑 |
| TMBOY | 44:c1d8923072ba | 15 | |
| TMBOY | 44:c1d8923072ba | 16 | 1. 用户发query:帮我看看这是什么水果 |
| TMBOY | 44:c1d8923072ba | 17 | 2. 服务端返回ImageRecognizer.StartRecognize directive, 包含type参数:水果 |
| TMBOY | 44:c1d8923072ba | 18 | 3. 客户端拍照(或者截图、让用户选图片)后返回ImageRecognizer.Recognize event, 包含type参数:水果,url参数:图片地址,message_id是步骤2中的message_id |
| TMBOY | 44:c1d8923072ba | 19 | 4. 中控把event发给负责图像识别的bot,返回结果(可能要根据da的需求,返回多轮标志) |
| TMBOY | 44:c1d8923072ba | 20 | |
| TMBOY | 44:c1d8923072ba | 21 | 如果不是完全由语音发起的操作,客户端可以直接由步骤3开始,不传message_id,这种情况下后端需要有明确的图片处理bot |
| TMBOY | 44:c1d8923072ba | 22 | |
| TMBOY | 44:c1d8923072ba | 23 | ## ImageRecognizer.StartRecognize指令 |
| TMBOY | 44:c1d8923072ba | 24 | |
| TMBOY | 44:c1d8923072ba | 25 | 在[响应](../api/response.md)中的directives字段中的一项 |
| TMBOY | 44:c1d8923072ba | 26 | |
| TMBOY | 44:c1d8923072ba | 27 | ```javascript |
| TMBOY | 44:c1d8923072ba | 28 | { |
| TMBOY | 44:c1d8923072ba | 29 | "header": { |
| TMBOY | 44:c1d8923072ba | 30 | "namespace": "ImageRecognizer", |
| TMBOY | 44:c1d8923072ba | 31 | "name": "StartRecognize", |
| TMBOY | 44:c1d8923072ba | 32 | "message_id": "message_id-1344" |
| TMBOY | 44:c1d8923072ba | 33 | }, |
| TMBOY | 44:c1d8923072ba | 34 | "payload": { |
| TMBOY | 44:c1d8923072ba | 35 | "type":"水果" |
| TMBOY | 44:c1d8923072ba | 36 | } |
| TMBOY | 44:c1d8923072ba | 37 | } |
| TMBOY | 44:c1d8923072ba | 38 | ``` |
| TMBOY | 44:c1d8923072ba | 39 | |
| TMBOY | 44:c1d8923072ba | 40 | |
| TMBOY | 44:c1d8923072ba | 41 | |
| TMBOY | 44:c1d8923072ba | 42 | ## ImageRecognizer.Recognize 事件 |
| TMBOY | 44:c1d8923072ba | 43 | 识别图片的请求 |
| TMBOY | 44:c1d8923072ba | 44 | |
| TMBOY | 44:c1d8923072ba | 45 | 在[请求](../api/request.md)中的device_event字段 |
| TMBOY | 44:c1d8923072ba | 46 | |
| TMBOY | 44:c1d8923072ba | 47 | ```javascript |
| TMBOY | 44:c1d8923072ba | 48 | { |
| TMBOY | 44:c1d8923072ba | 49 | "device_event":{ |
| TMBOY | 44:c1d8923072ba | 50 | "header": { |
| TMBOY | 44:c1d8923072ba | 51 | "namespace": "ImageRecognizer", |
| TMBOY | 44:c1d8923072ba | 52 | "name": "Recognize", |
| TMBOY | 44:c1d8923072ba | 53 | "message_id": "message_id-1344" |
| TMBOY | 44:c1d8923072ba | 54 | }, |
| TMBOY | 44:c1d8923072ba | 55 | "payload": { |
| TMBOY | 44:c1d8923072ba | 56 | "type":"水果", //可选 |
| TMBOY | 44:c1d8923072ba | 57 | "url":"http://f10.baidu.com/it/u=2640880481,1295783988&fm=72" |
| TMBOY | 44:c1d8923072ba | 58 | } |
| TMBOY | 44:c1d8923072ba | 59 | } |
| TMBOY | 44:c1d8923072ba | 60 | } |
| TMBOY | 44:c1d8923072ba | 61 | ``` |
| TMBOY | 44:c1d8923072ba | 62 |
