阿里云視覺智能開放平臺(VIAPI)人臉人體之人臉信息脫敏Java SDK使用說明
發(fā)布時間:2022-02-25 點(diǎn)擊數(shù):1134
簡介: 本文介紹人臉信息脫敏BlurFace Java SDK的語法及示例。
功能描述
人臉信息脫敏能力對輸入圖像中的人臉進(jìn)行模糊處理,輸出脫敏后的圖像。
前提條件
請確保您已開通人臉人體服務(wù),若未開通服務(wù)請立即開通。
輸入限制
- 圖像格式:JPEG、JPG、PNG、BMP。
- 圖像大?。翰怀^3 MB。
- 圖像分辨率:大于32x32像素,小于5000×5000像素。
- URL地址中不能包含中文字符。
請求參數(shù)
ImageURL(String):圖像URL地址。當(dāng)前僅支持上海地域的OSS鏈接,如何生成URL請參見生成臨時上海地域URL。
返回數(shù)據(jù)
RequestID(String):請求ID。
Data(Object):數(shù)據(jù)返回結(jié)果內(nèi)容對象。
ImageURL(String):脫敏后的URL地址。(該URL地址為臨時地址,有效期為30分鐘,過期后將無法訪問。)
下載安裝
導(dǎo)入Maven依賴文件
<dependency> <groupId>com.aliyun</groupId> <artifactId>aliyun-java-sdk-facebody</artifactId> <version>1.2.28</version> </dependency>
代碼示例
實(shí)現(xiàn)代碼示例
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 BlurFace { public static void main(String[] args) {
DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", "<your-access-key-id>", "<your-access-key-secret>"); /** use STS Token
DefaultProfile profile = DefaultProfile.getProfile(
"<your-region-id>", // The region ID
"<your-access-key-id>", // The AccessKey ID of the RAM account
"<your-access-key-secret>", // The AccessKey Secret of the RAM account
"<your-sts-token>"); // STS Token
**/ IAcsClient client = new DefaultAcsClient(profile);
BlurFaceRequest request = new BlurFaceRequest();
request.setImageURL("http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/facebody/BlurFace/BlurFace1.png"); try {
BlurFaceResponse response = client.getAcsResponse(request);
System.out.println(new Gson().toJson(response));
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
System.out.println("ErrCode:" + e.getErrCode());
System.out.println("ErrMsg:" + e.getErrMsg());
System.out.println("RequestId:" + e.getRequestId());
}
}
}