阿里云智能视觉生产图像处理人像分割Java SDK使用说明

简介: 人像分割用于识别输入图像中的人体轮廓,与背景进行分离,返回分割后的前景人像图(4通道),适用于单人、多人、复杂背景、各类人体姿态等场景。本文介绍如何使用阿里云智能视觉生产图像处理人体分割Java SDK,包括SDK的安装方法及SDK代码示例。

下载安装

 <dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>aliyun-java-sdk-ivpd</artifactId>
    <version>1.0.2</version>
</dependency>
<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>aliyun-java-sdk-core</artifactId>
    <version>4.4.9</version>
</dependency>
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>1.2.60</version>
</dependency>
<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.5.3</version>
</dependency>

代码示例

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.aliyuncs.*;
import com.aliyuncs.http.ProtocolType;
import com.aliyuncs.ivpd.model.v20190625.*;
import com.aliyuncs.profile.DefaultProfile;
import org.apache.http.util.Asserts;
import java.util.*;

public class ZhiNengShiJueShengChan {
    static IAcsClient client = null;
    static String regionId = "cn-beijing";
    public static void main(String[] args) throws Exception {
        DefaultProfile profile = DefaultProfile.getProfile(regionId, "accessKeyId", "accessKey secret");
        profile.getHttpClientConfig().setMaxRequests(100);
        profile.getHttpClientConfig().setMaxRequestsPerHost(50);
        client = new DefaultAcsClient(profile);
        testSegmentBody();//人像分割
    }
    public static SegmentBodyResponse testSegmentBody() throws Exception {
        SegmentBodyRequest req = new SegmentBodyRequest();
        System.out.print("--------  人像分割 -----");
        req.setImageUrl(formatDemoUrl("SegmentBody/mayun.jpeg"));
        SegmentBodyResponse resp = getAcsResponse(req);
        printResponse(req.getSysActionName(), resp.getRequestId(), resp.getCode(), resp.getMessage(), resp.getData());
        return resp;
    }
public static void printResponse(String action, String requestId, String code, String message, Object data) {
        System.out.print("  " + action + " ======================================\n");
        System.out.println("requestId:  " + requestId);
        System.out.println("code:  " + code);
        System.out.println(" msg:  " + message);
        System.out.println("body.class:  " + data == null ? null : data.getClass());
        System.out.println("body:  " + JSON.toJSONString(data, SerializerFeature.PrettyFormat));
        Asserts.check("0".equals(code), "assert code == 0 req:");
        Asserts.check(null != data, "assert data != null");
        System.out.println("\n");
    }
    private static <R extends RpcAcsRequest<T>, T extends AcsResponse> T getAcsResponse(R req) throws Exception {
        req.setSysProtocol(ProtocolType.HTTPS);
        return client.getAcsResponse(req);
    }
    private static String formatDemoUrl(String file) {
        return String.format("http://ivpd-%s.oss-%s.aliyuncs.com/ivpd-demo/images/%s", regionId, regionId, file);
    }
}

参考链接

SegmentBody人像分割

目录
相关文章
|
4月前
|
Java API 开发工具
百宝箱开放平台 ✖️ Java SDK
百宝箱提供Java SDK,支持开发者集成其开放能力。需先发布应用,准备Java 8+及Maven环境,通过添加依赖安装SDK,并初始化客户端调用对话型或生成型智能体,实现会话管理、消息查询与文件上传等功能。
1370 0
百宝箱开放平台 ✖️ Java SDK
|
8月前
|
存储 Java API
MinIO Java SDK 7.1.4 升级到 8.5.17 需要注意什么
现在我需要你帮我分析对比这个两个sdk在对外的接口设计上是否有不兼容的变更
637 5
|
Java Apache 开发工具
【Azure 事件中心】 org.slf4j.Logger 收集 Event Hub SDK(Java) 输出日志并以文件形式保存
【Azure 事件中心】 org.slf4j.Logger 收集 Event Hub SDK(Java) 输出日志并以文件形式保存
250 1
|
存储 Java API
【Azure 存储服务】Java Storage SDK 调用 uploadWithResponse 代码示例(询问ChatGTP得代码原型后人力验证)
【Azure 存储服务】Java Storage SDK 调用 uploadWithResponse 代码示例(询问ChatGTP得代码原型后人力验证)
179 0
|
Java 开发工具
通过Java SDK调用阿里云模型服务
在阿里云平台上,可以通过创建应用并使用模型服务完成特定任务,如生成文章内容。本示例展示了一段简化的Java代码,演示了如何调用阿里云模型服务生成关于“春秋战国经济与文化”的简短文章。示例代码通过设置系统角色为历史学家,并提出文章生成需求,最终处理并输出生成的文章内容。在实际部署前,请确保正确配置环境变量中的密钥和ID,并根据需要调整SDK导入语句及类名。更多详情和示例,请参考相关链接。
|
JSON Java API
【Azure API 管理】通过Java APIM SDK创建一个新的API,如何为Reqeust的Representation设置一个内容示例(Sample)?
【Azure API 管理】通过Java APIM SDK创建一个新的API,如何为Reqeust的Representation设置一个内容示例(Sample)?
140 0
|
存储 Java 开发工具
【Azure 存储服务】Java Azure Storage SDK V12使用Endpoint连接Blob Service遇见 The Azure Storage endpoint url is malformed
【Azure 存储服务】Java Azure Storage SDK V12使用Endpoint连接Blob Service遇见 The Azure Storage endpoint url is malformed
221 0
|
5月前
|
开发工具 Android开发
X Android SDK file not found: adb.安卓开发常见问题-Android SDK 缺少 `adb`(Android Debug Bridge)-优雅草卓伊凡
X Android SDK file not found: adb.安卓开发常见问题-Android SDK 缺少 `adb`(Android Debug Bridge)-优雅草卓伊凡
656 11
X Android SDK file not found: adb.安卓开发常见问题-Android SDK 缺少 `adb`(Android Debug Bridge)-优雅草卓伊凡
|
前端开发 Java Shell
【08】flutter完成屏幕适配-重建Android,增加GetX路由,屏幕适配,基础导航栏-多版本SDK以及gradle造成的关于fvm的使用(flutter version manage)-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
【08】flutter完成屏幕适配-重建Android,增加GetX路由,屏幕适配,基础导航栏-多版本SDK以及gradle造成的关于fvm的使用(flutter version manage)-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
804 20
【08】flutter完成屏幕适配-重建Android,增加GetX路由,屏幕适配,基础导航栏-多版本SDK以及gradle造成的关于fvm的使用(flutter version manage)-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
|
JavaScript 前端开发 Java
[Android][Framework]系统jar包,sdk的制作及引用
[Android][Framework]系统jar包,sdk的制作及引用
507 0