|
|
@@ -2,8 +2,14 @@ package me.zhengjie.application.bank.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.arcsoft.face.*;
|
|
|
+import com.arcsoft.face.enums.DetectMode;
|
|
|
+import com.arcsoft.face.enums.DetectOrient;
|
|
|
+import com.arcsoft.face.enums.ErrorInfo;
|
|
|
+import com.arcsoft.face.toolkit.ImageInfo;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import me.zhengjie.annotation.rest.AnonymousGetMapping;
|
|
|
import me.zhengjie.annotation.rest.AnonymousPostMapping;
|
|
|
import me.zhengjie.application.admin.service.SmsTemplateService;
|
|
|
import me.zhengjie.application.bank.service.BankNotarizeService;
|
|
|
@@ -22,6 +28,12 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static com.arcsoft.face.toolkit.ImageFactory.getRGBData;
|
|
|
+
|
|
|
@Validated
|
|
|
@RestController
|
|
|
@RequestMapping("${fqgz.bank.app.url-prefix}")
|
|
|
@@ -163,4 +175,92 @@ public class BankNotarizeController {
|
|
|
}
|
|
|
return userAXQInfoService.uploadSeal(businessNo, jsonArray);
|
|
|
}
|
|
|
+
|
|
|
+ @AnonymousGetMapping("/active-arcsoft")
|
|
|
+ public ResponseDTO<?> activeArcsoft() {
|
|
|
+ //从官网获取
|
|
|
+ String appId = "6F5JVsCCeSEbBSLSXWVwPki71yK5Y4Jf7oUjA4Y3mLtu";
|
|
|
+ String sdkKey = "5qKM4a9oNSXNhXdwd7Ycrvnxdw2JXjcyeccYmb4zND7S";
|
|
|
+ FaceEngine faceEngine = new FaceEngine("/Users/sakuya/Downloads/arcsoft_lib");
|
|
|
+ //激活引擎
|
|
|
+ int errorCode = faceEngine.activeOnline(appId, sdkKey);
|
|
|
+ if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
|
|
+ System.out.println("引擎激活失败");
|
|
|
+ } else {
|
|
|
+ System.out.println("引擎激活成功");
|
|
|
+ }
|
|
|
+ //引擎卸载
|
|
|
+ errorCode = faceEngine.unInit();
|
|
|
+ return ResponseDTO.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @AnonymousGetMapping("/face-compare")
|
|
|
+ public ResponseDTO<?> faceCompare() {
|
|
|
+ // 从官网获取
|
|
|
+ String appId = "6F5JVsCCeSEbBSLSXWVwPki71yK5Y4Jf7oUjA4Y3mLtu";
|
|
|
+ String sdkKey = "5qKM4a9oNSXNhXdwd7Ycrvnxdw2JXjcyeccYmb4zND7S";
|
|
|
+ FaceEngine faceEngine = new FaceEngine("/home/tom/nt/lib/so");
|
|
|
+ // 人脸比对
|
|
|
+ ActiveFileInfo activeFileInfo = new ActiveFileInfo();
|
|
|
+ int errorCode = faceEngine.getActiveFileInfo(activeFileInfo);
|
|
|
+ if (errorCode != ErrorInfo.MOK.getValue() && errorCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
|
|
|
+ System.out.println("获取激活文件信息失败");
|
|
|
+ }
|
|
|
+ //引擎配置
|
|
|
+ EngineConfiguration engineConfiguration = new EngineConfiguration();
|
|
|
+ engineConfiguration.setDetectMode(DetectMode.ASF_DETECT_MODE_IMAGE);
|
|
|
+ engineConfiguration.setDetectFaceOrientPriority(DetectOrient.ASF_OP_ALL_OUT);
|
|
|
+ engineConfiguration.setDetectFaceMaxNum(10);
|
|
|
+ engineConfiguration.setDetectFaceScaleVal(16);
|
|
|
+ //功能配置
|
|
|
+ FunctionConfiguration functionConfiguration = new FunctionConfiguration();
|
|
|
+ functionConfiguration.setSupportAge(true);
|
|
|
+ functionConfiguration.setSupportFace3dAngle(true);
|
|
|
+ functionConfiguration.setSupportFaceDetect(true);
|
|
|
+ functionConfiguration.setSupportFaceRecognition(true);
|
|
|
+ functionConfiguration.setSupportGender(true);
|
|
|
+ functionConfiguration.setSupportLiveness(true);
|
|
|
+ functionConfiguration.setSupportIRLiveness(true);
|
|
|
+ engineConfiguration.setFunctionConfiguration(functionConfiguration);
|
|
|
+ //初始化引擎
|
|
|
+ errorCode = faceEngine.init(engineConfiguration);
|
|
|
+ if (errorCode != ErrorInfo.MOK.getValue()) {
|
|
|
+ System.out.println("初始化引擎失败");
|
|
|
+ }
|
|
|
+ //人脸检测
|
|
|
+ ImageInfo imageInfo = getRGBData(new File("/home/tom/nt/test/aaa.jpeg"));
|
|
|
+ List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
|
|
+ errorCode = faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
|
|
|
+ System.out.println(faceInfoList);
|
|
|
+
|
|
|
+ //特征提取
|
|
|
+ FaceFeature faceFeature = new FaceFeature();
|
|
|
+ errorCode = faceEngine.extractFaceFeature(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList.get(0), faceFeature);
|
|
|
+ System.out.println("特征值大小:" + faceFeature.getFeatureData().length);
|
|
|
+
|
|
|
+ //人脸检测2
|
|
|
+ ImageInfo imageInfo2 = getRGBData(new File("/home/tom/nt/test/bbb.jpeg"));
|
|
|
+ List<FaceInfo> faceInfoList2 = new ArrayList<FaceInfo>();
|
|
|
+ errorCode = faceEngine.detectFaces(imageInfo2.getImageData(), imageInfo2.getWidth(), imageInfo2.getHeight(),imageInfo2.getImageFormat(), faceInfoList2);
|
|
|
+ System.out.println(faceInfoList2);
|
|
|
+
|
|
|
+ //特征提取2
|
|
|
+ FaceFeature faceFeature2 = new FaceFeature();
|
|
|
+ errorCode = faceEngine.extractFaceFeature(imageInfo2.getImageData(), imageInfo2.getWidth(), imageInfo2.getHeight(), imageInfo2.getImageFormat(), faceInfoList2.get(0), faceFeature2);
|
|
|
+ System.out.println("特征值大小:" + faceFeature2.getFeatureData().length);
|
|
|
+
|
|
|
+ //特征比对
|
|
|
+ FaceFeature targetFaceFeature = new FaceFeature();
|
|
|
+ targetFaceFeature.setFeatureData(faceFeature.getFeatureData());
|
|
|
+ FaceFeature sourceFaceFeature = new FaceFeature();
|
|
|
+ sourceFaceFeature.setFeatureData(faceFeature2.getFeatureData());
|
|
|
+ FaceSimilar faceSimilar = new FaceSimilar();
|
|
|
+
|
|
|
+ errorCode = faceEngine.compareFaceFeature(targetFaceFeature, sourceFaceFeature, faceSimilar);
|
|
|
+
|
|
|
+ System.out.println("相似度:" + faceSimilar.getScore());
|
|
|
+ //引擎卸载
|
|
|
+ errorCode = faceEngine.unInit();
|
|
|
+ return ResponseDTO.success();
|
|
|
+ }
|
|
|
}
|