提交 a096ee4c authored 作者: yangqi's avatar yangqi

1

上级 68dbed34
...@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author 杨奇 * @author 杨奇
...@@ -46,4 +47,11 @@ public class FaceController { ...@@ -46,4 +47,11 @@ public class FaceController {
faceService.updateFace(dbName, entityId, labels); faceService.updateFace(dbName, entityId, labels);
return new ApiResponse<>(); return new ApiResponse<>();
} }
@NoAuth
@GetMapping("/getFace")
public ApiResponse<Object> updateFace(String dbName, String entityId) throws Exception {
Map<String, Object> map = faceService.getFace(dbName, entityId);
return new ApiResponse<>(map);
}
} }
...@@ -63,24 +63,6 @@ public class HikvisionService { ...@@ -63,24 +63,6 @@ public class HikvisionService {
client.createFaceDbWithOptions(request, runtime); client.createFaceDbWithOptions(request, runtime);
} }
/**
* @link {https://help.aliyun.com/document_detail/161145.html}
*/
public static Map<String, Object> getFace(String dbName, String entityId) throws Exception {
com.aliyun.facebody20191230.Client client = createClient();
com.aliyun.facebody20191230.models.GetFaceEntityRequest request = new com.aliyun.facebody20191230.models.GetFaceEntityRequest();
request.setDbName(dbName);
request.setEntityId(entityId);
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
GetFaceEntityResponse res = client.getFaceEntityWithOptions(request, runtime);
GetFaceEntityResponseBody.GetFaceEntityResponseBodyData data = res.getBody().data;
Map<String, Object> map = new HashMap<>();
map.put("labels", data.getLabels());
map.put("faces", data.getFaces());
return map;
}
/** /**
* @link {https://help.aliyun.com/document_detail/159216.html} * @link {https://help.aliyun.com/document_detail/159216.html}
*/ */
......
package cn.lefull.common.sdk.ali.base; package cn.lefull.common.sdk.ali.base;
import com.aliyun.com.viapi.FileUtils; import com.aliyun.com.viapi.FileUtils;
import com.aliyun.facebody20191230.models.ListFaceDbsRequest; import com.aliyun.facebody20191230.models.*;
import com.aliyun.facebody20191230.models.ListFaceDbsResponse;
import com.aliyun.facebody20191230.models.ListFaceDbsResponseBody;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Component @Component
...@@ -111,6 +111,27 @@ public class Face { ...@@ -111,6 +111,27 @@ public class Face {
client.updateFaceEntityWithOptions(request, runtime); client.updateFaceEntityWithOptions(request, runtime);
} }
/**
* @link {https://help.aliyun.com/document_detail/161145.html}
*/
public Map<String, Object> getFace(String dbName, String entityId) throws Exception {
com.aliyun.facebody20191230.Client client = createClient();
com.aliyun.facebody20191230.models.GetFaceEntityRequest request = new com.aliyun.facebody20191230.models.GetFaceEntityRequest();
request.setDbName(dbName);
request.setEntityId(entityId);
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
GetFaceEntityResponse res = client.getFaceEntityWithOptions(request, runtime);
GetFaceEntityResponseBody.GetFaceEntityResponseBodyData data = res.getBody().data;
if(data == null){
return null;
}
Map<String, Object> map = new HashMap<>();
map.put("labels", data.getLabels());
map.put("faces", data.getFaces());
return map;
}
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);
......
...@@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author 杨奇 * @author 杨奇
...@@ -35,4 +36,10 @@ public class FaceService { ...@@ -35,4 +36,10 @@ public class FaceService {
Utils.checkParamsNotEmpty(entityId, "entityId"); Utils.checkParamsNotEmpty(entityId, "entityId");
face.updateFace(dbName, entityId, labels); face.updateFace(dbName, entityId, labels);
} }
public Map<String, Object> getFace(String dbName, String entityId) throws Exception {
Utils.checkParamsNotEmpty(dbName, "dbName");
Utils.checkParamsNotEmpty(entityId, "entityId");
return face.getFace(dbName, entityId);
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论