Android 之 一键抠图,抠人像

Android 之 一键抠图,抠人像,超简单,唯一的缺点就是就是要花钱

# 1,三方开发平台,需要注册一下 佐糖,买个key

```

https://picwish.cn/background-removal-api-doc#/

```

# 2,postman接口测试:

https://techsz.aoscdn.com/api/tasks/visual/segmentation

请求Headers :

```

"X-API-KEY": "这个就是花钱买的码,有个免费的可以使用几次的"

```

请求Body :

```

{

"image_base64":"图片base64字串,注意不要带前缀",

"sync":1, // 这个是同步异步选择int类型,填1就是同步返回结果

"type":"person"

}

```

请求成功返回:

```

{

"status": 200,

"data": {

"completed_at": 1679038527,

"created_at": 1679038527,

"download_time": 14,

"err_info": "",

"foreground_rect": {

"x": 0,

"y": 0,

"width": 1080,

"height": 1066

},

"image": "https://wxtechsz.oss-cn-shenzhen.aliyuncs.com/tasks/output/segmentation/816dd719-89e0-437a-8c3c-3eb40983dae2-image.png?Expires=1679042128&OSSAccessKeyId=LTAI5tGjJnh66c1txANiRBQN&Signature=fxU%2BIGzkwbdVF04%2Bn69j3iWM0fw%3D",

"output_type": 2,

"processed_at": 1679038527,

"progress": 100,

"result_type": "person",

"return_type": 1,

"state": 1,

"task_id": "816dd719-89e0-437a-8c3c-3eb40983dae2",

"time_elapsed": 413.06,

"type": "person"

}

}

```

# 直接选择同步请求就行

```

OkHttpClient okHttpClient = new OkHttpClient.Builder().build();

RequestBody requestBody = new MultipartBody.Builder()

.setType(MultipartBody.FORM)

.addFormDataPart("image_file", {YOUR_JPG_PATH}, RequestBody.create({JPG_FILE}, MediaType.parse("image/jpeg")))

.addFormDataPart("sync", 1)

.build();

Request request = new Request.Builder()

.url("https://techsz.aoscdn.com/api/tasks/visual/segmentation")

.addHeader("X-API-KEY", "{YOUR_API_KEY}")

.post(requestBody)

.build();

Response response = okHttpClient.newCall(request).execute();

```

作为it牛马,欢迎兄弟姐妹们留言,是对我最大的鼓励

你可能感兴趣的:(android,android,studio)