绘本识别
<h3>概述</h3>
<p>该文档是<strong>绘本识别</strong>接口,主要用于接收<strong>识别结果</strong>通知,开发者需要继承虚类VTRecognizeNotify并实现其方法。
通过该类可用于扩展实现其它功能,例如:表情灯显示表情。</p>
<h3>注意:</h3>
<p><strong><em>我们的通知回调不能处理太多业务,否则会造成识别线程阻塞</em></strong></p>
<hr />
<h4>1. 类定义</h4>
<p>类定义如下:
``` c++</p>
<p>class VTRecognizeNotify {
public:
VTRecognizeNotify() {
printf("Create VTRecognizeNotify.\n");
}
virtual ~VTRecognizeNotify() {</p>
<pre><code> printf("Destroy VTRecognizeNotify.\n");
}
virtual void onUpdateStatus(int RecogStatus, RecogInfo info) { //更新识别状态
}</code></pre>
<p>};</p>
<pre><code>
#### 2. 更新状态
该接口实例会被绘本sdk内部调用,用于将识别结果通知给sdk外部的应用,
通过此接口,可以获取识别到的书本信息、书页信息及翻书状态。
- **接口原型:**</code></pre>
<p>void onUpdateStatus(int RecogStatus, RecogInfo info);;</p>
<pre><code>- **参数:**
| 参数 | 类型 | 说明 |
| ------------ | ------------ | ---- |
| RecogStatus | int | 翻书状态值 |
| info | RecogInfo | 书本及书页信息 |
- **返回值:** 无
| 返回值 | 类型 | 说明 |
| ------------ | ------------ | ----- |
| - | - | - |
#### 3. 翻书状态定义:
翻书状态通过枚举表示。如下:
``` c++
enum RecogStatus {
BOOK_CHANGE = 0, //换书
BOOK_NEWPAGE = 1, //翻页
BOOK_MOVE = 2, //移动或者翻书
};</code></pre>
<h4>4. 获取到的书本及书页信息定义</h4>
<p>书本信息只有在RecogStatus为BOOK_CHANGE和BOOK_NEWPAGE时有效;
开发者可通过此接口获取到的信息</p>
<ul>
<li><strong>书本信息</strong>如下:</li>
</ul>
<table>
<thead>
<tr>
<th>属性</th>
<th>类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>book_id</td>
<td>int</td>
<td>书本ID</td>
</tr>
<tr>
<td>bookname</td>
<td>std::string</td>
<td>书名</td>
</tr>
<tr>
<td>author</td>
<td>std::string</td>
<td>作者</td>
</tr>
<tr>
<td>publisher</td>
<td>std::string</td>
<td>出版社</td>
</tr>
<tr>
<td>bookclass</td>
<td>std::string</td>
<td>书本系列</td>
</tr>
<tr>
<td>bookintroduction</td>
<td>std::string</td>
<td>书本简介</td>
</tr>
<tr>
<td>isbn</td>
<td>std::string</td>
<td>ISBN号</td>
</tr>
<tr>
<td>thumbnail_url</td>
<td>std::string</td>
<td>书本封面缩略图的URL</td>
</tr>
<tr>
<td>total_extra_data</td>
<td>std::string</td>
<td>书本扩展数据</td>
</tr>
<tr>
<td>page_num</td>
<td>int</td>
<td>物理页总数</td>
</tr>
<tr>
<td>book_type</td>
<td>int</td>
<td>书本类型 (预留,未使用)</td>
</tr>
</tbody>
</table>
<ul>
<li><strong>书页信息</strong>如下:</li>
</ul>
<table>
<thead>
<tr>
<th>属性</th>
<th>类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>book_id</td>
<td>long</td>
<td>书本ID</td>
</tr>
<tr>
<td>page_id</td>
<td>long</td>
<td>书页ID</td>
</tr>
<tr>
<td>page_type</td>
<td>int</td>
<td>书页类型,定义如下个表格</td>
</tr>
<tr>
<td>reg_num</td>
<td>int</td>
<td>页码,页码应是属于某个书页类型下的序号,比如扉页的第1页,正文的第1页</td>
</tr>
<tr>
<td>physical_num</td>
<td>int</td>
<td>物理页码 [物理页码的定义]( <a href="https://www.showdoc.cc/visiontalk?page_id=2217052330244112">https://www.showdoc.cc/visiontalk?page_id=2217052330244112</a> "物理页码定义")</td>
</tr>
<tr>
<td>physical_sate</td>
<td>int</td>
<td>物理页状态</td>
</tr>
<tr>
<td>extra_data</td>
<td>std::string</td>
<td>扩展数据,特别标识字段</td>
</tr>
</tbody>
</table>
<ul>
<li>书本类型有哪些</li>
</ul>
<table>
<thead>
<tr>
<th style="text-align: center;">page_type值</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">1</td>
<td>封面</td>
</tr>
<tr>
<td style="text-align: center;">2</td>
<td>封里</td>
</tr>
<tr>
<td style="text-align: center;">3</td>
<td>扉页</td>
</tr>
<tr>
<td style="text-align: center;">4</td>
<td>目录</td>
</tr>
<tr>
<td style="text-align: center;">5</td>
<td>正文</td>
</tr>
<tr>
<td style="text-align: center;">6</td>
<td>辅文 (前言,后记,引文,注文,附录,索引,参考文献)</td>
</tr>
<tr>
<td style="text-align: center;">7</td>
<td>封底里</td>
</tr>
<tr>
<td style="text-align: center;">8</td>
<td>封底</td>
</tr>
<tr>
<td style="text-align: center;">9</td>
<td>其他</td>
</tr>
</tbody>
</table>
<ul>
<li>具体数据结构如下:</li>
</ul>
<pre><code>struct RecogInfo {
BookInfo bookinfo; //书本信息
PageInfo pageinfo; //书页信息
int code; //识别code
std::string msg; //识别结果信息
};
struct BookInfo {
long book_id; //书本ID
std::string bookname; //书名
std::string author; //作者
std::string publisher; //出版社
std::string bookclass; //书本系列
std::string bookintroduction; //简介
std::string isbn; //isbn
std::string thumbnail_url; //缩略图
std::string total_extra_data; //书本扩展数据(可以是json格式字符串)
int page_num; //物理页总数
int book_type; //书本类型 (预留)
};
struct PageInfo {
long book_id; //书本ID
long page_id; //书页ID
int page_type; //书页类型 1-封面 2-封里 3-扉页 4-目录 5-正文 6-辅文 7-封底里 8-封底 9-其他
int reg_num; //识别页码
int physical_num; //物理页码
int physical_sate; //物理页状态
std::string extra_data; //扩展数据,可以是json格式字符串
};
</code></pre>