你好,请问我使用视觉智能平台java的maven引入imageseg20191230的1.0.5?

8e34ceb86374f83e4bfd9254574a7aaa.png 你好,请问我使用视觉智能平台java的maven引入imageseg20191230的1.0.5,然后运行测试的时候报错。不引入就不会保存。sdk有什么问题吗?

展开
收起
真的很搞笑 2023-05-13 18:49:09 274 分享 版权
2 条回答
写回答
取消 提交回答
  • 公众号:网络技术联盟站,InfoQ签约作者,阿里云社区签约作者,华为云 云享专家,BOSS直聘 创作王者,腾讯课堂创作领航员,博客+论坛:https://www.wljslmz.cn,工程师导航:https://www.wljslmz.com

    要在Java项目中使用阿里云视觉智能平台的图像分割服务,您需要引入以下Maven依赖:

    <dependency>
        <groupId>com.aliyun</groupId>
        <artifactId>aliyun-java-sdk-core</artifactId>
        <version>4.5.3</version>
    </dependency>
    <dependency>
        <groupId>com.aliyun</groupId>
        <artifactId>aliyun-java-sdk-imageseg20191230</artifactId>
        <version>1.0.5</version>
    </dependency>
    

    其中,aliyun-java-sdk-core是阿里云Java SDK的核心依赖,aliyun-java-sdk-imageseg20191230是阿里云视觉智能平台的图像分割服务依赖,1.0.5是该服务的版本号。

    您可以在pom.xml文件中添加以上依赖,然后使用Maven构建项目。在代码中,您可以按照以下方式创建ImageSeg20191230Client实例,并调用图像分割服务:

    import com.aliyuncs.DefaultAcsClient;
    import com.aliyuncs.exceptions.ClientException;
    import com.aliyuncs.exceptions.ServerException;
    import com.aliyuncs.imageseg20191230.model.SegmentBodyRequest;
    import com.aliyuncs.imageseg20191230.model.SegmentBodyResponse;
    import com.aliyuncs.imageseg20191230.model.SegmentCommonImageRequest;
    import com.aliyuncs.imageseg20191230.model.SegmentCommonImageResponse;
    import com.aliyuncs.imageseg20191230.model.SegmentSkyRequest;
    import com.aliyuncs.imageseg20191230.model.SegmentSkyResponse;
    import com.aliyuncs.profile.DefaultProfile;
    import com.aliyuncs.profile.IClientProfile;
    import com.aliyuncs.visionai_common.model.Result;
    
    public class ImageSegDemo {
        public static void main(String[] args) {
            String accessKeyId = "your_access_key_id";
            String accessKeySecret = "your_access_key_secret";
            String regionId = "cn-shanghai";
    
            // 创建AcsClient实例
            IClientProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
            DefaultAcsClient client = new DefaultAcsClient(profile);
    
            // 创建分割人像请求
            SegmentBodyRequest bodyRequest = new SegmentBodyRequest();
            bodyRequest.setImageURL("https://your-image-url");
            try {
                SegmentBodyResponse bodyResponse = client.getAcsResponse(bodyRequest);
                Result result = bodyResponse.getData();
                System.out.println(result.getUrl());
            } catch (ServerException e) {
                e.printStackTrace();
            } catch (ClientException e) {
                e.printStackTrace();
            }
    
            // 创建分割通用图像请求
            SegmentCommonImageRequest commonImageRequest = new SegmentCommonImageRequest();
            commonImageRequest.setImageURL("https://your-image-url");
            try {
                SegmentCommonImageResponse commonImageResponse = client.getAcsResponse(commonImageRequest);
                Result result = commonImageResponse.getData();
                System.out.println(result.getUrl());
            } catch (ServerException e) {
                e.printStackTrace();
            } catch (ClientException e) {
                e.printStackTrace();
            }
    
            // 创建分割天空请求
            SegmentSkyRequest skyRequest = new SegmentSkyRequest();
            skyRequest.setImageURL("https://your-image-url");
            try {
                SegmentSkyResponse skyResponse = client.getAcsResponse(skyRequest);
                Result result = skyResponse.getData();
                System.out.println(result.getUrl());
            } catch (ServerException e) {
                e.printStackTrace();
            } catch (ClientException e) {
                e.printStackTrace();
            }
        }
    }
    

    以上代码演示了如何使用Java SDK调用阿里云视觉智能平台的图像分割服务,并获取分割结果的URL。在实际使用中,您需要将accessKeyIdaccessKeySecret替换为您的阿里云账号的AccessKey ID和AccessKey Secret,将regionId替换为您选择的地域ID,将imageURL替换为您要分割的图像的URL。

    2023-05-14 08:04:15
    赞同 展开评论
  • SDK没问题的,你这样安装的嘛? com.aliyun imageseg20191230 1.0.5 ,此回答整理自钉群“阿里云视觉智能开放平台咨询1群”

    2023-05-13 19:11:59
    赞同 展开评论

为开发者提供高易用、普惠的视觉API服务,帮助企业快速建立视觉智能技术应用能力的综合性视觉AI能力平台。适用于数字营销、互联网娱乐、安防、手机应用、泛金融身份认证等行业。

收录在圈子:
阿里云视觉智能开放平台视觉AI能力问题咨询,请通过钉钉群(23109592)加入阿里云视觉智能开放平台咨询群
还有其他疑问?
咨询AI助理