物体抠图 API

优质
小牛编辑
121浏览
2023-12-01

自动识别图像中主体轮廓,与背景进行分离,返回分割后的Alpha图、前景物体图,适应多物体,复杂背景。服饰、男女装、鞋帽、首饰、箱包、化妆品、饮料、快销品、宠物等等,所有明确主体的品类都可以识别分割,电商特别适用,适应复杂背景和光线。

模式一

返回二进制文件流

模式二

返回base64字符串

模式三

通过图片URL返回base64结果

抠图API调用示例代码

github地址: https://github.com/picup-shop

  • cURL
  • Python
  • PHP
  • Java
  • nodejs
  • .net
  • Objective-C
  • curl -H 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
        -F 'file=@/path/to/file.jpg'     \
        -f 'https://picupapi.tukeli.net/api/v1/matting?mattingType=2' \
        -o out.png
  • curl -H 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
        -F 'file=@/path/to/file.jpg'     \
        -f 'https://picupapi.tukeli.net/api/v1/matting?mattingType=2' \
        -o out.png
  • curl -H 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
        -F 'file=@/path/to/file.jpg'     \
        -f 'https://picupapi.tukeli.net/api/v1/matting?mattingType=2' \
        -o out.png
  • curl -H 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
        -F 'file=@/path/to/file.jpg'     \
        -f 'https://picupapi.tukeli.net/api/v1/matting?mattingType=2' \
        -o out.png
  • curl -H 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
        -F 'file=@/path/to/file.jpg'     \
        -f 'https://picupapi.tukeli.net/api/v1/matting?mattingType=2' \
        -o out.png
  • curl -H 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
        -F 'file=@/path/to/file.jpg'     \
        -f 'https://picupapi.tukeli.net/api/v1/matting?mattingType=2' \
        -o out.png
  • curl -H 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
        -F 'file=@/path/to/file.jpg'     \
        -f 'https://picupapi.tukeli.net/api/v1/matting?mattingType=2' \
        -o out.png

API文档说明

接口描述

用户向服务请求获取某张图中的人物,服务器返回人物的PNG图片。

请求说明

  • 请求URl: https://picupapi.tukeli.net/api/v1/matting?mattingType=2
  • 请求方式: POST
  • 返回类型: PNG图像
  • 输入参数:

    (1) 请求参数(Header)

    参数参数类型描述
    Content-Typestringmultipart/form-data
    APIKEYstring您的专属API Key

    (2) 请求参数(Body)

    参数必填
    file图片文件
    crop是否裁剪至最小非透明区域,url参数,加在url后面,false不裁剪,true裁剪,不填写不裁剪
    bgcolor填充背景色,url参数,加在url后面,十六进制大小RGB颜色,如FFFFFF,不填写不填充背景色

返回说明

  • 正常返回

    直接返回content-type为image/png,图片处理后的二进制文件。

  • 错误返回
    {
      "code": 1001, //
      "data": null
      "msg": '余额不足',
      "time": 1590462453264
    }

抠图API调用示例代码

github地址: https://github.com/picup-shop

  • cURL
  • Python
  • PHP
  • Java
  • nodejs
  • .net
  • Objective-C
  • curl -H 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
         -F 'file=@/path/to/file.jpg'     \
         -f 'https://picupapi.tukeli.net/api/v1/matting2?mattingType=2&crop=true'
  • curl -H 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
         -F 'file=@/path/to/file.jpg'     \
         -f 'https://picupapi.tukeli.net/api/v1/matting2?mattingType=2&crop=true'
  • curl -H 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
         -F 'file=@/path/to/file.jpg'     \
         -f 'https://picupapi.tukeli.net/api/v1/matting2?mattingType=2&crop=true'
  • curl -H 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
         -F 'file=@/path/to/file.jpg'     \
         -f 'https://picupapi.tukeli.net/api/v1/matting2?mattingType=2&crop=true'
  • curl -H 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
         -F 'file=@/path/to/file.jpg'     \
         -f 'https://picupapi.tukeli.net/api/v1/matting2?mattingType=2&crop=true'
  • curl -H 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
         -F 'file=@/path/to/file.jpg'     \
         -f 'https://picupapi.tukeli.net/api/v1/matting2?mattingType=2&crop=true'
  • curl -H 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
         -F 'file=@/path/to/file.jpg'     \
         -f 'https://picupapi.tukeli.net/api/v1/matting2?mattingType=2&crop=true'

API文档说明

接口描述

用户向服务请求获取某张图中的人物,服务器返回人物通过base64编码后的结果。

请求说明

  • 请求URl: https://picupapi.tukeli.net/api/v1/matting2?mattingType=2
  • 请求方式: POST
  • 返回类型: PNG图像
  • 输入参数:

    (1) 请求参数(Header)

    参数参数类型描述
    Content-Typestringmultipart/form-data
    APIKEYstring您的专属API Key

    (2) 请求参数(Body)

    参数必填
    file图片文件
    crop是否裁剪至最小非透明区域,url参数,加在url后面,false不裁剪,true裁剪,不填写不裁剪
    bgcolor填充背景色,url参数,加在url后面,十六进制大小RGB颜色,如FFFFFF,不填写不填充背景色
    faceAnalysis人脸检测点信息,为true返回带人脸检测信息

返回说明

  • 正常返回
    {
        "code": 0,
        "data": {
        "imageBase64": "iVBORw0KGgo..." //返回图像的base64编码
        },
        "msg": null,
        "time": 1590462453264
    }
  • 返回带人脸检测信息
    {
       "code": 0,
       "data":{
          "imageBase64":"iVBORw0KGgoAAAANSUhEUgAABqMAAAg3CAYAAAC7wX7xAAAgAElE....",
          "faceAnalysis":{
              "face_num": 1, //人脸数量
              "faces": [  //face_num*8 数组,含义为p1(x,y),p3(x,y),p2(x,y),p4(x,y)(参考图片)
                   [
                       236.4606096446514,
                       497.67069862782955,
                       1492.7539091706276,
                       2050.210829436779,
                       236.4606096446514,
                       497.67069862782955,
                       1492.7539091706276,
                       2050.210829436779
                   ]
               ]
              "point":[
                 [
                    [
                       213.5859375, //x轴点位
                       1035.0703125 //y轴点位
                    ],
                    [
                       221.80078125,
                       1219.904296875
                    ]
                    ......//一共返回68个点位,按数组索引值顺序请参考下方点位图片,数值默认为x,y
                 ]
              ]
          }
       },
       "msg": null,
       "time": 1620798570850
    }

    点位图片

  • 错误返回
    {
      "code": 1001, //
      "data": null
      "msg": '余额不足',
      "time": 1590462453264
    }

抠图API调用示例代码

github地址: https://github.com/picup-shop

  • cURL
  • Objective-c
  • curl -X GET --header 'Accept: application/json' \
        --header 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
        'https://picupapi.tukeli.net/api/v1/mattingByUrl?url=http%3A%2F%2Fdeeplor.oss-cn-hangzhou.aliyuncs.com%2Fupload%2Fimage%2F20200721%2F6ed6a205f75d4f4c88fb403700712191.jpg&mattingType=2'
  • curl -X GET --header 'Accept: application/json' \
        --header 'APIKEY: INSERT_YOUR_API_KEY_HERE' \
        'https://picupapi.tukeli.net/api/v1/mattingByUrl?url=http%3A%2F%2Fdeeplor.oss-cn-hangzhou.aliyuncs.com%2Fupload%2Fimage%2F20200721%2F6ed6a205f75d4f4c88fb403700712191.jpg&mattingType=2'

API文档说明

接口描述

用户向服务请求获取某张图中的人物,服务器返回人物通过base64编码后的结果。

请求说明

  • 请求URl: https://picupapi.tukeli.net/api/v1/mattingByUrl
  • 请求方式: GET
  • 返回类型: application/json
  • 输入参数:

    (1) 请求参数(Header)

    参数参数类型描述
    APIKEYstring您的专属API Key

    (2) 请求参数(Body)

    参数必填
    mattingType抠图类型,1:人像,2:物体,3:头像,4:一键美化,6:通用抠图,11:卡通化,17: 卡通头像,18: 人脸变清晰, 19: 照片上色
    crop是否裁剪至最小非透明区域,url参数,加在url后面,false不裁剪,true裁剪,不填写不裁剪
    bgcolor填充背景色,url参数,加在url后面,十六进制大小RGB颜色,如FFFFFF,不填写不填充背景色
    url图片的url地址
    faceAnalysis人脸检测点信息,为true返回带人脸检测信息
  • 正常返回
    {
        "code": 0,
        "data": {
        "imageBase64": "iVBORw0KGgo..." //返回图像的base64编码
        },
        "msg": null,
        "time": 1590462453264
    }
  • 返回带人脸检测信息
    {
       "code": 0,
       "data":{
          "imageBase64":"iVBORw0KGgoAAAANSUhEUgAABqMAAAg3CAYAAAC7wX7xAAAgAElE....",
          "faceAnalysis":{
              "face_num": 1, //人脸数量
              "faces": [  //face_num*8 数组,含义为p1(x,y),p3(x,y),p2(x,y),p4(x,y)(参考图片)
                   [
                       236.4606096446514,
                       497.67069862782955,
                       1492.7539091706276,
                       2050.210829436779,
                       236.4606096446514,
                       497.67069862782955,
                       1492.7539091706276,
                       2050.210829436779
                   ]
               ]
              "point":[
                 [
                    [
                       213.5859375, //x轴点位
                       1035.0703125 //y轴点位
                    ],
                    [
                       221.80078125,
                       1219.904296875
                    ]
                    ......//一共返回68个点位,按数组索引值顺序请参考下方点位图片,数值默认为x,y
                 ]
              ]
          }
       },
       "msg": null,
       "time": 1620798570850
    }

    点位图片

  • 错误返回
    {
      "code": 1001, //
      "data": null
      "msg": '余额不足',
      "time": 1590462453264
    }