# 1. 实时事件上报

SE3 实时事件上报内容请参考：[SE3实时事件上报](/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/7.1-shi-shi-shi-jian-shang-bao-nei-rong.md)。

## 其他SE AI计算盒实时事件上报：

**功能描述：**

SE AI计算盒实时上报所有比对事件到管理平台。

**调用方法**

调用方法: WebSocket

1）websocket端口为：ws\://IP:5679

2）连接成功之后不会发送任何东西，接下来需要对ws进行配置：

主要配置以下几个字段：

| 参数名            | 类型   | 默认值   | 说明                                     |
| -------------- | ---- | ----- | -------------------------------------- |
| need\_face     | bool | False | 是否要返回现场人脸图，数据类型为base64编码的jpg           |
| need\_register | bool | False | 是否需要返回注册的底库图，比对通过的情况，数据类型为base64编码的jpg |
| event\_list    | list | \[ ]  | 需要实时推送的device id list                  |

3）ws有event之后，会根据配置来决定是否需要进行推送

4）获取设备id可以用如下Get接口获取：

<http://IP:5555/SophonDevice/api/Devices>

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

|                |                  |        |        |                                                                    |                       |
| -------------- | ---------------- | ------ | ------ | ------------------------------------------------------------------ | --------------------- |
| **一级参数**       | **二级参数**         | **类型** | **选择** | **说明**                                                             | 举例                    |
| identity\_id   |                  | string | **必选** | 用户编号                                                               | "12345565"            |
| device\_id     |                  | string | **必选** | 产生event的设备id，uuid                                                  |                       |
| identity\_name |                  | string | **必选** | 用户名称                                                               | "Tom"                 |
| identity\_info |                  | dict   | **必选** | 人员底库注册时候的info字段，陌生人为空字典                                            |                       |
| group\_name    |                  | string | **必选** | 比对的group name，如果没有group\_name返回group\_id                           | "default\_group"      |
| reg\_pic       |                  | base64 | 可选     | 注册的人脸底库，默认上传，可配置去除                                                 | "/9j/6QAEAAD/2wBD..." |
| timestamp      |                  | int32  | **必选** | 事件发生的时间戳                                                           | 1565771454932         |
| score          |                  | float  | **必选** | 比对的分数                                                              | 0.78                  |
| ext\_data      |                  | dict   | **必选** | 拓展数据字段，可迭代添加                                                       |                       |
|                | device\_ip       | sting  | **必选** | 设备ip                                                               | "192.168.1.101"       |
|                | spot\_pic        | base64 | 可选     | 现场照片，迎宾机模式下不传                                                      | "/9j/6QAEAAD/2wBD..." |
|                | recognize\_face  | base64 | 可选     | 背景图中经过剪切后的人脸图                                                      | "/9j/xxewAAD/wds2..." |
|                | 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得人脸质量检测结果，详细参考历史信息详情示例(臻识抓拍机有效)                            |                       |

**返回信息：**

```
{
    "reg_pic":"/9j/6QAEAAD/2wBD...",
    "ext_data":{
        "person_type":5,
        "grab_fiqa_info":{

        },
        "device_ip":"192.168.1.243",
        "box_fiqa_info":{

        },
        "device_type":"0",
        "spot_pic":"/9j/6QAEAAD/2wBD..."，
        "recognize_face":"/9j/xxewAAD/wds2..."
    },
    "identity_id":"666666",
    "device_id":"23c7232b-0b35-4813-be6b-6ec4ee21ac4f",
    "identity_info":{
            "image_id" : "7bab3d75-ae0b-44db-bbbd-8d5eb788385a",
        "permission_ids" : [ 
            "9ded10eff6804f3da4d99c25fcaf7383"
        ],
        "type" : 1,
        "user_id" : "01220615",
        "face_ids" : [ 
            "53be77f3-91a7-4835-bbb8-1cced2354785"
        ],
        "name" : "ran93717829",
        "ext_info" : {
            "building_no" : "1",
            "room" : "101",
            "address" : "address",
            "floor" : "1"
        }
    }
    "score":0.6231614351272583,
    "timestamp":1566016554020,
    "group_name":"default_group",
    "identity_name":"小明"
}
```

websocket获取结果示例：

```
import websocket
import json
s=websocket.WebSocket()
s.connect('ws://192.168.1.52:5679')
config = {'need_face':True, 'need_register':True, 'event_list':["04f98265-1fad-47e5-9dda-66e191272055", "f9f0768f-497c-45f3-9307-ae80a9d89390", "804b1218-218e-4465-8e1f-c305a5981001", "9483034a-da64-4db0-b223-64e87d5567db"]}
json_data = json.dumps(config)
s.send(json_data)
while True:
info = s.recv_data(4096)
event = json.loads(str(info[1], encoding='utf8'))
print("{} {}".format(event['video_id'], event['event_id']))
```


---

# 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/v5r5c01_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/7.1-shi-shi-shi-jian-shang-bao-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.
