# 2. 历史事件上报

**功能描述**

上报所有事件（数据库保存所有Event字段）给云平台。需要和监控服务器约定url，假设/EventServer/api/HistoryEvent

**调用URL**

调用方法: POST

**参数描述（JSON格式）：**

|           |                |                  |        |        |                                                                                                 |                                                         |
| --------- | -------------- | ---------------- | ------ | ------ | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
| **index** | **一级参数**       | **二级参数**         | 类型     | **选择** | **说明**                                                                                          | 举例                                                      |
| 1         | identity\_id   |                  | string | **必选** | 用户编号                                                                                            | "13435454"                                              |
| 2         | identity\_name |                  | string | **必选** | 用户名称                                                                                            | "Tom"                                                   |
| 3         | group\_name    |                  | string | **必选** | 比对的group name，如果没有group\_name返回group\_id                                                        | "default\_group"                                        |
| 4         | reg\_pic       |                  | base64 | 可选     | 注册的人脸底库，可配置去除                                                                                   |                                                         |
| 5         | timestamp      |                  | int32  | **必选** | 事件发生的时间戳                                                                                        | 1565771454932                                           |
| 6         | score          |                  | float  | **必选** | 比对的分数                                                                                           | 0.23                                                    |
| 7         | want\_action   |                  | string | **必选** | <p>根据该字段判断需要进行的操作：<br>”0“：默认值， 不进行额外操作。<br>”1001“：新的陌生人注册。<br>”1002“：人脸注册底库更新。</p>              | ”0“                                                     |
| 8         | ext\_data      |                  | dict   | **必选** | 拓展数据字段，可迭代添加                                                                                    |                                                         |
|           |                | device\_ip       | string | **必选** | 设备ip                                                                                            | "192.168.1.101"                                         |
|           |                | ep\_id           | string | **必选** | <p>边缘节点ID，是指SE3 AI迷你机连接的采集设备的ID。<br>ID：dev\_sno和IP的组合，用双下划线做连接。举例：AKOPKKKKK\_\_192.168.1.25</p> | "3714be15-09b3-41ec-b9ce-62b668e5fa32\_\_192.168.1.101" |
|           |                | spot\_pic        | base64 | 可选     | 现场照片                                                                                            |                                                         |
|           |                | recognize\_face  | base64 | 可选     | 背景图中的每张人脸图                                                                                      |                                                         |
|           |                | person\_type     | int    | **必选** | <p>1:员工（默认为员工，包括这个字段不存在的情况）<br>2: 访客<br>3: 黑名单<br>4：陌生人<br>5：VIP</p>                            | 1                                                       |
|           |                | device\_type     | string | **必选** | <p>0：闸机，<br>1：抓拍机<br>3：IPC 动态<br>4：门禁</p>                                                       | 0                                                       |
|           |                | grab\_fiqa\_info | dict   | **必选** | 其他设备模式内容为空（抓拍机模式下只有臻识抓拍机有效），返回抓拍机得人脸质量检测结果，详细请看示例                                               | {}                                                      |
|           |                | box\_fiqa\_info  | dict   | **必选** | 其他设备模式内容为空(抓拍机模式有值)，返回AI BOX得人脸质量检测结果，详细请看示例                                                    | {}                                                      |
|           |                | dev\_sno         | string | **必选** | SE3 AI迷你机唯一标识授权码                                                                                |                                                         |

**返回信息：**

```json
{
	'score': 0.16, 
	'reg_pic': 'xxx', 
	'group_name': 'default_group', 
	'identity_id': '13028', 
	'identity_name': 'stranger', 
    "want_action":"0",
	'timestamp': 1560408984678, 
	'ext_data': {
			'device_type': '1', 
			'grab_fiqa_info': {   //臻识抓拍机返回的信息
					'confidence': 90, 
					'face_id': 1381, 
					'rect': {'top': 420, 'bottom': 524, 'right': 1734, 'left': 1652}, 
					'pitch': 0, 
					'age': 4, 
					'rel_rect': {'top': 62, 'bottom': 166, 'right': 134, 'left': 52}, 
					'yaw': 0, 
					'eye_dist': 82, 
					'roll': 0, 
					'sex': 1}, //性别0为男， 1为女
			'spot_pic': 'xxxxx', 
        	'recognize_face':"xxx",
			'box_fiqa_info': {   //AI BOX端返回的图片质量检测信息
					'age':4,
					'sex':1, //性别0为男，1为女
					'info': {'face_size': 255.0, 
                   'clarity': 1.285613331998212, 
                   'headpose': {'roll_angle': 10.107, 'pitch_angle': 14.413, 'yaw_angle': 7.326},
                   'partial': False, 
                   'brightness': 0.8362176798557405},  //图片质量检测的参数
					'fiqa_result': True,    //fiqa是否合格的标志，True表示图片质量比较好
					'success': ['face_size', 'clarity', 'headpose', 'partial', 'brightness'], 
					'fails': []}, 
			'person_type': 1,   //通过此处的人员类型来判断是否是陌生人，如果是person_type为4， 则是陌生人，且fiqa_result为False，则说明陌生人的图片质量不是很好，不能进行再次下发注册
			 'device_ip': '192.168.1.151'}
}
```

**示例：**

可以使用小盒子附带的server来获取上传的事件。

假设小盒子的ip为：192.168.1.19，接收的resetful api为HistoryEvent ，端口号为9528。

那webui或是配置/修改历史事件上报接收服务器地址信息为：[http://192.168.1.19:9528/HistoryEvent](http://192.168.1.19:9528/RealTimeEvent)

启动server方法：

```shell
$ sudo -i
\# cd /system/data/sophon_gate/script
\# python3 Event_Receive_server.py
* Serving Flask app "Event_Receive_server" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://0.0.0.0:9528/ (Press CTRL+C to quit)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bm168x.gitbook.io/project/v2r4c01_readme/xi-tong-dui-jie-shuo-ming-shu/dui-jie-se3-he-zi/7.-she-bei-shang-bao-xin-xi-de-jie-kou-gui-fan/9-yi-bu-shang-bao-shi-jian-ju-ti-nei-rong.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
