[关闭]
@sewise-dev 2018-04-10T10:26:28.000000Z 字数 6158 阅读 664

人脸识别服务

  1. 列表项

人脸API


更新历史

编号 版本 说明 作者 创建日期 修改日期
1 v1.3 创建文档 zewise 2017-10-26 2018-4-8


目录

(1)人脸表情API接口

1 创建group接口 ##暂时没有用

|post http://ip:8080/creategroup|

参数 类型 说明 必选
groupid 字符串 group名字,必须填写
userdata 字符串 group描述信息

例子:

curl -X POST -d "groupname=betaface" -d "userdata=test" http://192.168.1.48:8080/creategroup

回应body json

{"status":11000,"message":"delete Face Person Failure: not found"}
200 success
11000 Create Face Person Group Failure
12000 The name is empty
14000 unsupport the method

2 删除group接口 ##暂时没有用

|post http://ip:8080/creategroup|

参数 类型 说明 必选
groupname 字符串 group名字,必须填写

例子:

curl -X POST -d "groupid=betaface" http://192.168.1.48:8080/removegroup

回应body json

{"status":11000,"message":"delete Face Person Failure: not found"}
200 success
11000 Create Face Person Group Failure
12000 The name is empty
14000 unsupport the method

3 添加单个人脸入特征库

|post http://ip:8080/addperson|

参数 类型 说明 必选
groupid 字符串 以学校为单位的groupid, 为创建group接口的groupid
username 字符串 人脸名字,必须填写, 如果信息不重要可以用"abc"代理,暂不支持中文
uid 字符串 用户uid信息。
file 二进制数据 人脸图片数据

例子:

curl -X POST -F "file=@/neutral20171017184940.jpg" -F "username=hongyu" -F "uid=123" -F "groupid=testface" http://192.168.1.48:8080/addperson

回应body json

{"status":11000,"message":"delete Face Person Failure: not found"}
200 success
11000 the file storage failure
12000 The name or uid is empty
13000 Add Face Person Failure
14000 unsupport the method

4 删除单个人脸入特征库

|post http://ip:8080/removeperson|

参数 类型 说明 必选
groupid 字符串 以学校为单位的groupid, 为创建group接口的groupid
username 字符串 人脸名字,必须填写, 如果信息不重要可以用"abc"代理
uid 字符串 人脸uid信息。

例子:

curl -X POST -d "username=hongyu" -d "uid=123" -d "groupid=testface" http://192.168.1.48:8080/removeperson

回应body json

{"status":11000,"message":"delete Face Person Failure: not found"}
200 success
11000 delete Face Person Failure
12000 The name or uid is empty
14000 unsupport the method

(2)相机部分API接口

5 上传图片进行识别

|post http://ip:8080/upload|

参数 类型 说明 必选
groupid 字符串 以学校为单位的groupid, 为创建group接口的groupid
time 字符串 图片拍照时间,必须填写, 如果信息不重要可以用"abc"代理
file 二进制数据 人脸图片数据

例子:

curl -X POST -F "file=@/neutral20171017184940.jpg" -F "time=20171002" -F "sn=1123124" http://192.168.1.48:8080/upload

6 sn注册和绑定

|post http://ip:8080/register|

参数 类型 说明 必选
school 字符串 学校id
sn 字符串 相机sn

例子:

curl -X POST -d "school=abcd" -d "sn=2h2h2h" http://192.168.1.48:8080/register

11000 "Register sn Failure: " + err.Error()
12000 "The school name or sn is empty"
13000 "the Sn is exist"
14000 "unsupport the method"

6 sn解除绑定

|post http://ip:8080/unregister|

参数 类型 说明 必选
sn 字符串 相机sn

例子:

curl -X POST -F "sn=2h2h2h" http://192.168.1.48:8080/unregister

11000 "UnRegister sn Failure: " + err.Error()
12000 "The sn is empty"
13000 "the Sn is exist"
14000 "unsupport the method"

#mqtt订阅方式:

USR_CLOUD "43104d7b146bbb8a172c6814901f1044"
PASSWD_CLOUD "1052559b943048b3bf03990a6eb736c5"
COMPANYID_CLOUD "78904e0fce90d1b15c385141204aa58d"
COMPANY_CLOUD "sewise"

服务端订阅主题:
----消息主题: "/COMPANYID_CLOUD/COMPANY_CLOUD/camera_pub/#"

相机端订阅主题;
----消息主题: "/COMPANYID_CLOUD/COMPANY_CLOUD/camera_sub/sn" sn为相机的sn码

给相机发指令: publish /COMPANYID_CLOUD/COMPANY_CLOUD/camera_sub/sn

例如: 服务地址 vtest.sewise.com:1883

--------接收到的消息:
注册消息
----camera---->注册消息 "{"cmd":0xFF, "sn":"2k2k2k", "version":"v1.0.0"}"

预览推流消息
----server---->推流消息 "{"cmd":0x4, "url":"rtmp://vtest.sewise.com/live/stream"}"
url 为推流地址
<---camera------------------回应 "{"cmd":0x4, "success":ture}"
----server---->停止推流消息 "{"cmd":0x5}"
<---camera------------------回应 "{"cmd":0x5, "success":ture}"

拍照消息
----server---->开始拍照消息 "{"cmd":0x6, "url":"http://vtest.sewise.com:10001/upload", "interval":10}"
url 是图片服务器url
interval 是拍照周期
<---camera------------------回应 "{"cmd":0x6,"url":"http://vtest.sewise.com:10001/upload","interval":10,"success":ture}"
----server---->停止拍照消息 "{"cmd":0x7}"
<---camera------------------回应 "{"cmd":0x7, "success":ture}"

OTA升级
----server---->开始拍照消息 "{"cmd":0x8, "url":"http://120.122.1.1:80## 标题 ##/liveapp"}"
url 是固件地址url
<---camera------------------回应 "{"cmd":0x8,"url":"http://120.122.1.1:80/liveapp","success":ture}"
<---camera------------------回调 "{"cmd":0x8, "update":true, "version":"v1.0.0"}"

版本查询
----server---->开始拍照消息 "{"cmd":0x9}"
<---camera------------------回调 "{"cmd":0x9, "version":"v1.0.0"}"

录制消息
----server---->录制消息 "{"cmd":0x11, "filename":"test.mp4"}"
<---camera------------------回应 "{"cmd":0x10, "success":ture}"
<---camera------------------回调 "{"cmd":0x10, "time_sec":12123123, "time_usec":123}"
time_sec: 为1970到现在秒
time_usec: 精确到毫秒
表示录制开始的时间
----server---->停止推流消息 "{"cmd":0x12}"
<---camera------------------回应 "{"cmd":0x11, "success":ture}"
<---camera------------------回调 "{"cmd":0x11, "filename":"name1.mp4#name2.mp4name3.mp5", "srcfilename":"test.mp4","time_sec":12123123, "time_usec":123}"
name1.mp4为分片的文件名字。例如1.MP4 2.MP4 3.MP4 组装起来就是"1.MP4#2.MP4#3.MP4"。"#"符号连接
srcfilename 为录制开始时候传入的文件名.
time_sec: 为1970到现在秒
time_usec: 精确到毫秒
表示录制结束的时间

遗嘱消息主题: "/COMPANYID_CLOUD/COMPANY_CLOUD/camera/will"
遗嘱消息的内容:
"{"sn":"2k2k2k2k"}"
在线状态可以通过遗嘱消息来判断。

(2)人脸识别服务API接口

1 上传特征码进行人脸识别

|post http://ip:8080/upload||

参数 类型 说明 必选
featrue 字符串 人脸特征值信息

回应:

{"status": 200, "message":"zhangsan"}
status: 200(成功) 非200均为失败, message 成功时为正确识别的名字。 失败时为失败原因

例子:

curl -X POST -F "featrue=@./feature/kaihong.txt" http://192.168.1.48:8080/upload

2 上传特征码进行人脸注册(用于APP)

|post http://ip:8080/register||

参数 类型 说明 必选
featrue 字符串 人脸特征值信息
username 字符串 注册名字
image 二进制信息串 注册图片

回应:

{"status": 200, "message":"register sucess"}
status: 200(成功) 非200均为失败, message 失败时为失败原因

例子:

curl -X POST -F "featrue=@./feature/kaihong.txt" -F "username=haihong" -F "image=@/cammer/facelib/lib/gukaihong.jpg" http://192.168.1.48:8080/register

3 上传图片进行人脸注册(用于PC)

|post http://ip:8080/imageregister||

参数 类型 说明 必选
username 字符串 注册名字
image 二进制信息串 注册图片

回应:

{"status": 200, "message":"register sucess"}
status: 200(成功) 非200均为失败, message 失败时为失败原因

例子:

curl -X POST -F "username=haihong" -F "image=@/cammer/facelib/lib/gukaihong.jpg" http://192.168.1.48:8080/imageregister

4 删除人脸注册信息

|post http://ip:8080/delete||

参数 类型 说明 必选
username 字符串 注册名字

回应:

{"status": 200, "message":"delete sucess"}
status: 200(成功) 非200均为失败, message 失败时为失败原因

例子:

curl -X POST -F "username=haihong" http://192.168.1.48:8080/delete

5 服务激活API

|post http://ip:8080/activate||

参数 类型 说明 必选
authentication 字符串 授权码(授权码生成详见源码说明)

回应:

{"status":200,"message":"authenticate success"}
status: 200(成功) 非200均为失败, message 失败时为失败原因

例子:

curl -X POST -F "authentication=@./authtest.data" http://192.168.1.48:8080/activate

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注