[关闭]
@superpigy 2022-11-28T13:32:14.000000Z 字数 5018 阅读 643

平台API接口

请求接口上传文件上限 1M

BaseURL: https://weapp.ai.hamuna.club

Token API

  1. AccessToken获取

    URL:

    1. /access_token/acquire

    Header 包括:

    1. content-type: multipart/form-data
    2. app_id: 获取的app_id

    方法: POST

    参数:

    1. {
    2. 'signature': aes(app_id={app_id}&timestamp={timestamp}&noncer={noncer}, app_secret),
    3. 'client_id': 'client_id' // 目标设备ID,需固定,
    4. 'is_refresh': 'yes'
    5. }

    需注意: AI接口请求头也需加上client_id

    返回样例:

    1. {
    2. "success": "ok",
    3. "data": {
    4. "token": {
    5. "token": "eb4785d4a4e14b6e9d8c9eb97a92341e",
    6. "expired_time": 1584517993
    7. },
    8. "noncer": "random"
    9. }
    10. }

    参数说明:

参数 说明 是否必须 类型
app_id 获取的app_id str
timestamp UTC毫秒数 str
noncer 随机字符串, 会返回到客户端, 避免中间人攻击 str
app_secret app秘钥

用秘钥加密连接字符串得到签名, 正式服务器Token有效期为7200秒, 测试服务器有效时间无限. AES为ECB加密并使用Base64编码, 块大小为32,Padding

  1. AccessToken刷新(已弃用)

    URL:

    1. /access_token/refresh

    请求头

    1. content-type: multipart/form-data
    2. app_id: 获取的app_id

    方法: POST

    参数:

    1. {
    2. token: {your token}
    3. }

    返回样例:

    1. {
    2. "success": "ok",
    3. "data": {
    4. "token": {
    5. "token": "eb4785d4a4e14b6e9d8c9eb97a92341e",
    6. "expired_time": 1584518850
    7. }
    8. }
    9. }

    参数说明:

参数 说明 是否必须 类型
token 上次获取的Token str

该API返回新的Token,过期时间为时间戳

Counting API

猪圈点数
URL:

```
/ml/pig_count
```

**请求头:**
```

content-type: multipart/form-data
app_id: 获取的app_id
client_id: 申请token的client_id
token: 获取的token
```
返回样例:

  1. {
  2. "success": "ok",
  3. "data": {
  4. "location": [
  5. [
  6. 0.44792890548706055,
  7. 0.530472457408905,
  8. 0.6128923296928406,
  9. 0.6608350276947021,
  10. 0.8791984915733337
  11. ],
  12. [
  13. 0.3167198598384857,
  14. 0.32818686962127686,
  15. 0.41282859444618225,
  16. 0.5314476490020752,
  17. 0.8544944524765015
  18. ],
  19. ...
  20. ],
  21. "infer_node_id": 'infer' # 結果來自哪個推理節點
  22. "count": 22
  23. },
  24. "errMsg": ""
  25. }

参数:

参数 说明 是否必须 类型
file 点数图片 jpg
lat 地理坐标 float
lng 地理坐标 float
device_desc 设备描述 jpg

点数范围location中每一个item前4个为定位坐标(归一化), 分别为,第五个为检测置信度得分
到原图的映射坐标计算公式,默认已经恢复到正常尺度, 如果没有,请根据公式恢复到正常尺度:


其中代表输入图片的宽高

Counting API V2

猪圈点数
URL:

```
/ml/pig_count
```

**请求头:**
```

content-type: multipart/form-data
app_id: 获取的app_id
client_id: 申请token的client_id
token: 获取的token
```
返回样例:

  1. {
  2. "success": "ok",
  3. "data": {
  4. "location": [
  5. [
  6. 0.44792890548706055,
  7. 0.530472457408905,
  8. 0.6128923296928406,
  9. 0.6608350276947021,
  10. 0,
  11. 0.8791984915733337
  12. ],
  13. [
  14. 0.3167198598384857,
  15. 0.32818686962127686,
  16. 0.41282859444618225,
  17. 0.5314476490020752,
  18. 0,
  19. 0.8544944524765015
  20. ],
  21. ...
  22. ],
  23. "infer_node_id": 'infer' # 結果來自哪個推理節點
  24. "count": 22
  25. },
  26. "errMsg": ""
  27. }

参数:

参数 说明 是否必须 类型
file 点数图片 jpg
lat 地理坐标 float
lng 地理坐标 float
device_desc 设备描述 jpg
v2 值为1则使用新版本猪点数,不填则使用老版本点数 int

点数范围location中每一个item前4个为定位坐标(归一化), 分别为,最后一个为检测置信度得分

其中代表输入图片的宽高

監管攝像頭猪点数
URL:

  1. /ml/pig_count_cam

请求头:

  1. content-type: multipart/form-data
  2. app_id: 获取的app_id
  3. client_id: 申请tokenclient_id
  4. token: 获取的token

返回样例:

  1. {
  2. "success": "ok",
  3. "data": {
  4. "location": [
  5. [
  6. 0.44792890548706055,
  7. 0.530472457408905,
  8. 0.6128923296928406,
  9. 0.6608350276947021,
  10. 0.8791984915733337
  11. ],
  12. [
  13. 0.3167198598384857,
  14. 0.32818686962127686,
  15. 0.41282859444618225,
  16. 0.5314476490020752,
  17. 0.8544944524765015
  18. ],
  19. ...
  20. ],
  21. "infer_node_id": 'infer' # 結果來自哪個推理節點
  22. "count": 22
  23. },
  24. "errMsg": ""
  25. }

参数:

参数 说明 是否必须 类型
file 点数图片 jpg
lat 地理坐标 float
lng 地理坐标 float
device_desc 设备描述 jpg

点数范围location中每一个item前4个为定位坐标(归一化), 分别为,第五个为检测置信度得分
到原图的映射坐标计算公式,默认已经恢复到正常尺度, 如果没有,请根据公式恢复到正常尺度:


其中代表输入图片的宽高

Length & Weight API

  1. 死猪测长测重
    URL:

    1. /ml/pig_length_weight

    请求头:

    1. content-type: multipart/form-data
    2. app_id: 获取的app_id
    3. client_id: 申请tokenclient_id
    4. token: 获取的token

    返回样例:

    1. {
    2. "success": "ok",
    3. "data": {
    4. "weight": "16.07",
    5. "length": "60.75",
    6. "ml_output": {
    7. "bbox": [0.41155293583869934, 0.18497280776500702, 0.6115382313728333, 0.8869619369506836] #猪身位置,
    8. "keypoints": [
    9. [0, 0.5544663071632385, 0.7754763960838318],
    10. [1, 0.5544663071632385, 0.7754763960838318],
    11. ...
    12. ] # 关键点位置
    13. }
    14. },
    15. "errMsg": ""
    16. }

    参数:

参数 说明 是否必须 类型
file 点数图片 jpg
lat 地理坐标 float
lng 地理坐标 float
device_desc 设备描述 str
id 重复理赔id校验 str

长度为厘米, 重量为kg
猪身位置(bbox)前4个为0-1坐标
关键点位置(keypoints) 为 [id, x, y]
点取值范围: [0,1]
参考点数方法恢复点在图片上的尺度

masks为像素级猪身分割图, 值1所在的像素位置为猪身像素点位置,可参考mask绘图将猪身高亮显示

重复理赔校验id格式为"{保单号}|{理赔单号}"

  1. 死猪测长测重(带QRCode校验)
    URL:

    1. /ml/pig_length_weight_qrcode

    请求头:

    1. content-type: multipart/form-data
    2. app_id: 获取的app_id
    3. client_id: 申请tokenclient_id
    4. token: 获取的token

    返回样例:

    1. {
    2. "success": "ok",
    3. "data": {
    4. "weight": "16.07",
    5. "length": "60.75",
    6. "ml_output": {
    7. "bbox": [0.41155293583869934, 0.18497280776500702, 0.6115382313728333, 0.8869619369506836, 0.8508504629135132] #猪身位置,
    8. "keypoints": [
    9. [0.5544663071632385, 0.7754763960838318, 0.5],
    10. [0.5544663071632385, 0.7754763960838318, 0.5570072531700134],
    11. ...
    12. ] # 关键点位置
    13. }
    14. },
    15. "errMsg": ""
    16. }

    参数:

参数 说明 是否必须 类型
file 点数图片 jpg
lat 地理坐标 float
lng 地理坐标 float
device_desc 设备描述 str
qrcodes 识别到的二维码信息 list

参数qrcodes的格式为:

#QRCODE FORMAT
    [
        {
            'content': 'abcde',
            'x': 1,
            'y': 2,
        },
        {
            'content': 'abcde',
            'x': 1,
            'y': 2,
        }
    ]
    content 为二维码内容, x, y为二维码对应在图片上的坐标 范围[0, 1]

创建识别池

URL:

  1. /face_pool/create

请求头:

  1. content-type: multipart/form-data
  2. app_id: 获取的app_id
  3. client_id: 申请tokenclient_id
  4. token: 获取的token

返回样例:

  1. {
  2. "success": "ok",
  3. "data": {
  4. 'pool_id': ''
  5. },
  6. "errMsg": ""
  7. }

请求参数:

参数 说明 是否必须 类型
custom_id 自定义ID str
lat 地理坐标 float
lng 地理坐标 float
pool_info 识别池描述 dict
pool_type 识别池物种(传入cow即可) str
pool_name 识别池名称(保持唯一) str
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注