开发者学堂课程【达摩院视觉 AI 精品课:达摩院视觉 AI 介绍】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/912/detail/14418
达摩院视觉 AI 介绍(二)
三、演示:服务开通、调用
创建成功后显示如下:
点击操作中复制选项
复制信息如下:
用户名称登录 test2020lx2@43671.onaliyun.com
AccessKey ID LTA4G7We7Nir3zzdcp7G5x2
AccessKeySecretfLRIGqe8hKnsE77vleSraMYQdJTC4
创建用户后,给用户设置权限:
点击人员管理,进入用户项,点击添加权限选项
进入添加权限页面,进行权限管理:
点击确认后
上传图片地址到缺口:
搜索栏搜索 OSS,进入 OSS 控制台,点击 Bucket 列表,进入界面:
点击创建 Bucket,进入创建页面,输入 Bucket 名称,并选择地域:
将读写权限改为公共课,点击确定:
创建成功后呈如下界面:
创建文件:
点击文件管理,上传文件,进入上传文件界面,选择一个文件进行上传:
上传成功后,退出界面,点击详情,复制文件URL
使用 IDEA 创建一个新的 maven 项目,添加依赖包:
<dependency>
<groupId>com . aliyun</ groupid>
<artifactId>aliyun-java-sdk-core</artifactId><version>4.5.14</ version>
</ dependency>
<!-- https : / /mvnrepository.com/artifact/com.aliyun/aliyun-java-sdk-facebody -->
<dependency>
<groupid>com.aliyun</ groupId>
<artifactId>aliyun-java-sdk-facebody</ artifactId>
<version>1.2.2</version>
<
/dependency>
代码:
<?xml version="1,0"encoding="UTF-8"?>
<project xmlns="http://maven.apache. org/PON/4.0.0
“
xmlns:xsi="http:/ /www . w3.org/2001/XMLSchena-instance"
xsi:schemaLocation="http: //maven.apache .ong/PON/4.0.0 http://maven,apache .org/xsd/maven-
-
4
.0.0.
xsd
“>
<modelVersion>4.0.
0
</modelversion>
<groupId>org.example</groupId>
<artifactid>test002</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.5.14</version>
</ dependency>
<!--https://mvncenository,com/arntifact/com.aliyun/alivun-java-sdk-facebody -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-facebody</artifactId>
<version>1.2.2</version>
</dependency>
</dependencies>
</project>
将对应的包下载到本地并添加一个新的java类,输入代码如下:
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcSClient;
import com.aliyuncs.exceptions.clientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile;
import com.google.gson.Gson;
import java.util,*;
import
com.aliyuncs.facebody.model.v20191230,*;
public class DetectFace
{
public static void main(String[] args) {
DefaultProfile profile = DefaultProfile.getProfile( reglonld:“cn-shanghai",accesskeyid:"<accessKeyId> "
IAcsClient client = ne DefaultAcsclient(profile);
DetectFaceRequest request = new DetectFaceRequest(O;request.setRegionId( " cn-shanghai");
request.setImageURL ("httos://viapi-test.oss-cn-shanghai.aliyuncs .com/demo-center/facebody/DetectFace.jpg");
try
{
DetectFaceResponse response = client.getAcsResponse(request);
System.out.println(new Gson().toJson(response));
}
catch (serverException e){
e.printstackTrace(;
catch (clientException e)i
System.out.println( "ErrCode: " +e.getErrCode());
System.out.println( "ErrHsg;"+e.getErrMsg();
System.out.println( "RequestId: " + e.getRequestId());
}
}
}