提交 68dbed34 authored 作者: yangqi's avatar yangqi

1

上级 89438fb3
...@@ -39,4 +39,11 @@ public class FaceController { ...@@ -39,4 +39,11 @@ public class FaceController {
faceService.addFace(dbName, entityId, labels); faceService.addFace(dbName, entityId, labels);
return new ApiResponse<>(); return new ApiResponse<>();
} }
@NoAuth
@GetMapping("/updateFace")
public ApiResponse<Object> updateFace(String dbName, String entityId, String labels) throws Exception {
faceService.updateFace(dbName, entityId, labels);
return new ApiResponse<>();
}
} }
...@@ -63,55 +63,6 @@ public class HikvisionService { ...@@ -63,55 +63,6 @@ public class HikvisionService {
client.createFaceDbWithOptions(request, runtime); client.createFaceDbWithOptions(request, runtime);
} }
/**
* 查询人脸数据库列表
* @link {https://help.aliyun.com/document_detail/159142.html}
*/
public static List<String> getFaceDbList() throws Exception {
com.aliyun.facebody20191230.Client client = createClient();
com.aliyun.facebody20191230.models.ListFaceDbsRequest request = new com.aliyun.facebody20191230.models.ListFaceDbsRequest();
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
ListFaceDbsResponse res = client.listFaceDbsWithOptions(request, runtime);
List<ListFaceDbsResponseBody.ListFaceDbsResponseBodyDataDbList> dbList = res.getBody().data.dbList;
if (CollectionUtils.isEmpty(dbList)){
return new ArrayList<>();
}
return dbList.stream()
.map(ListFaceDbsResponseBody.ListFaceDbsResponseBodyDataDbList::getName)
.collect(Collectors.toList());
}
/**
* @link {https://help.aliyun.com/document_detail/161144.html}
*/
public static 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);
}
/**
* @link {https://help.aliyun.com/document_detail/161147.html}
*/
public static void updateFace(String dbName, String entityId, String labels) throws Exception {
com.aliyun.facebody20191230.Client client = createClient();
com.aliyun.facebody20191230.models.UpdateFaceEntityRequest request = new com.aliyun.facebody20191230.models.UpdateFaceEntityRequest();
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.updateFaceEntityWithOptions(request, runtime);
}
/** /**
* @link {https://help.aliyun.com/document_detail/161145.html} * @link {https://help.aliyun.com/document_detail/161145.html}
*/ */
......
...@@ -95,6 +95,22 @@ public class Face { ...@@ -95,6 +95,22 @@ public class Face {
client.addFaceEntityWithOptions(request, runtime); client.addFaceEntityWithOptions(request, runtime);
} }
/**
* 修改人脸样本
* @link {https://help.aliyun.com/document_detail/161147.html}
*/
public void updateFace(String dbName, String entityId, String labels) throws Exception {
com.aliyun.facebody20191230.Client client = createClient();
com.aliyun.facebody20191230.models.UpdateFaceEntityRequest request = new com.aliyun.facebody20191230.models.UpdateFaceEntityRequest();
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.updateFaceEntityWithOptions(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);
......
...@@ -20,13 +20,19 @@ public class FaceService { ...@@ -20,13 +20,19 @@ public class FaceService {
} }
public void createFaceDb(String dbName) throws Exception { public void createFaceDb(String dbName) throws Exception {
Utils.checkParamsNotEmpty(dbName, "dbName");
face.createFaceDb(dbName); face.createFaceDb(dbName);
} }
public void addFace(String dbName, String entityId, String labels) throws Exception { public void addFace(String dbName, String entityId, String labels) throws Exception {
Utils.checkParamsNotEmpty(dbName, "dbName"); Utils.checkParamsNotEmpty(dbName, "dbName");
Utils.checkParamsNotEmpty(entityId, "entityId"); Utils.checkParamsNotEmpty(entityId, "entityId");
Utils.checkParamsNotEmpty(labels, "labels");
face.addFace(dbName, entityId, labels); face.addFace(dbName, entityId, labels);
} }
public void updateFace(String dbName, String entityId, String labels) throws Exception {
Utils.checkParamsNotEmpty(dbName, "dbName");
Utils.checkParamsNotEmpty(entityId, "entityId");
face.updateFace(dbName, entityId, labels);
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论