提交 4abae0fa authored 作者: yangqi's avatar yangqi

1

上级 c6fc5afd
...@@ -3,6 +3,7 @@ package cn.lefull.api; ...@@ -3,6 +3,7 @@ package cn.lefull.api;
import cn.lefull.common.annotation.NoAuth; import cn.lefull.common.annotation.NoAuth;
import cn.lefull.common.response.ApiResponse; import cn.lefull.common.response.ApiResponse;
import cn.lefull.service.ali.FaceService; import cn.lefull.service.ali.FaceService;
import jdk.nashorn.internal.objects.annotations.Property;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -32,4 +33,12 @@ public class FaceController { ...@@ -32,4 +33,12 @@ public class FaceController {
faceService.createFaceDb(name); faceService.createFaceDb(name);
return new ApiResponse<>(); return new ApiResponse<>();
} }
@NoAuth
@GetMapping("/addFace")
public ApiResponse<Object> addFace(String dbName, String entityId, String labels) throws Exception {
//System.out.println("数据库名" + dbName + " entityId:" + entityId + " labels:" + labels);
faceService.addFace(dbName, entityId, labels);
return new ApiResponse<>();
}
} }
...@@ -79,6 +79,22 @@ public class Face { ...@@ -79,6 +79,22 @@ public class Face {
client.createFaceDbWithOptions(request, runtime); client.createFaceDbWithOptions(request, runtime);
} }
/**
* 添加人脸样本
* @link {https://help.aliyun.com/document_detail/161144.html}
*/
public void addFace(String dbName, String entityId, String labels) throws Exception {
com.aliyun.facebody20191230.Client client = createClient();
com.aliyun.facebody20191230.models.AddFaceEntityRequest request = new com.aliyun.facebody20191230.models.AddFaceEntityRequest();
request.setDbName(dbName);
request.setEntityId(entityId);
if(!labels.isEmpty()){
request.setLabels(labels);
}
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
client.addFaceEntityWithOptions(request, runtime);
}
public String uploadImageUrl(String file) throws com.aliyuncs.exceptions.ClientException, IOException { public String uploadImageUrl(String file) throws com.aliyuncs.exceptions.ClientException, IOException {
FileUtils fileUtils = FileUtils.getInstance(this.accessKeyId, this.accessKeySecret); FileUtils fileUtils = FileUtils.getInstance(this.accessKeyId, this.accessKeySecret);
return fileUtils.upload(file); return fileUtils.upload(file);
......
...@@ -21,4 +21,8 @@ public class FaceService { ...@@ -21,4 +21,8 @@ public class FaceService {
public void createFaceDb(String dbName) throws Exception { public void createFaceDb(String dbName) throws Exception {
face.createFaceDb(dbName); face.createFaceDb(dbName);
} }
public void addFace(String dbName, String entityId, String labels) throws Exception {
face.addFace(dbName, entityId, labels);
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论