|
@@ -66,7 +66,7 @@ public class FaceTestMd {
|
|
|
|
|
|
|
|
|
//人脸检测
|
|
|
- ImageInfo imageInfo = getRGBData(new File("D:\\计算机\\b9e4b8a58d3db22741714f8ad24d175.jpg"));
|
|
|
+ ImageInfo imageInfo = getRGBData(new File("D:\\javatext\\Zg5\\week1\\nekomimi\\images\\jincongrenlian.jpg"));
|
|
|
List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
|
|
errorCode = faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
|
|
|
System.out.println(faceInfoList);
|
|
@@ -77,91 +77,139 @@ public class FaceTestMd {
|
|
|
System.out.println("特征值大小:" + faceFeature.getFeatureData().length);
|
|
|
|
|
|
//人脸检测2
|
|
|
- ImageInfo imageInfo2 = getRGBData(new File("D:\\计算机\\030ab513d80c49522cbe28062ba5b7e.jpg"));
|
|
|
-// ImageInfo imageInfo2 = getRGBData(new File("D:\\计算机\\536d6c8a02947d1128642d34c009d06.jpg"));
|
|
|
- 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.setLivenessParam(0.5f, 0.7f);
|
|
|
- //人脸属性检测
|
|
|
- FunctionConfiguration configuration = new FunctionConfiguration();
|
|
|
- configuration.setSupportAge(true);
|
|
|
- configuration.setSupportFace3dAngle(true);
|
|
|
- configuration.setSupportGender(true);
|
|
|
- configuration.setSupportLiveness(true);
|
|
|
- errorCode = faceEngine.process(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList, configuration);
|
|
|
-
|
|
|
-
|
|
|
- //性别检测
|
|
|
- List<GenderInfo> genderInfoList = new ArrayList<GenderInfo>();
|
|
|
- errorCode = faceEngine.getGender(genderInfoList);
|
|
|
- System.out.println("性别:" + genderInfoList.get(0).getGender());
|
|
|
-
|
|
|
- //年龄检测
|
|
|
- List<AgeInfo> ageInfoList = new ArrayList<AgeInfo>();
|
|
|
- errorCode = faceEngine.getAge(ageInfoList);
|
|
|
- System.out.println("年龄:" + ageInfoList.get(0).getAge());
|
|
|
-
|
|
|
- //3D信息检测
|
|
|
- List<Face3DAngle> face3DAngleList = new ArrayList<Face3DAngle>();
|
|
|
- errorCode = faceEngine.getFace3DAngle(face3DAngleList);
|
|
|
- System.out.println("3D角度:" + face3DAngleList.get(0).getPitch() + "," + face3DAngleList.get(0).getRoll() + "," + face3DAngleList.get(0).getYaw());
|
|
|
-
|
|
|
- //活体检测
|
|
|
- List<LivenessInfo> livenessInfoList = new ArrayList<LivenessInfo>();
|
|
|
- errorCode = faceEngine.getLiveness(livenessInfoList);
|
|
|
- System.out.println("活体:" + livenessInfoList.get(0).getLiveness());
|
|
|
-
|
|
|
-
|
|
|
- //IR属性处理
|
|
|
- ImageInfo imageInfoGray = getGrayData(new File("D:\\计算机\\b9e4b8a58d3db22741714f8ad24d175.jpg"));
|
|
|
- List<FaceInfo> faceInfoListGray = new ArrayList<FaceInfo>();
|
|
|
- errorCode = faceEngine.detectFaces(imageInfoGray.getImageData(), imageInfoGray.getWidth(), imageInfoGray.getHeight(), imageInfoGray.getImageFormat(), faceInfoListGray);
|
|
|
-
|
|
|
- FunctionConfiguration configuration2 = new FunctionConfiguration();
|
|
|
- configuration2.setSupportIRLiveness(true);
|
|
|
- errorCode = faceEngine.processIr(imageInfoGray.getImageData(), imageInfoGray.getWidth(), imageInfoGray.getHeight(), imageInfoGray.getImageFormat(), faceInfoListGray, configuration2);
|
|
|
- //IR活体检测
|
|
|
- List<IrLivenessInfo> irLivenessInfo = new ArrayList<>();
|
|
|
- errorCode = faceEngine.getLivenessIr(irLivenessInfo);
|
|
|
- System.out.println("IR活体:" + irLivenessInfo.get(0).getLiveness());
|
|
|
-
|
|
|
- ImageInfoEx imageInfoEx = new ImageInfoEx();
|
|
|
- imageInfoEx.setHeight(imageInfo.getHeight());
|
|
|
- imageInfoEx.setWidth(imageInfo.getWidth());
|
|
|
- imageInfoEx.setImageFormat(imageInfo.getImageFormat());
|
|
|
- imageInfoEx.setImageDataPlanes(new byte[][]{imageInfo.getImageData()});
|
|
|
- imageInfoEx.setImageStrides(new int[]{imageInfo.getWidth() * 3});
|
|
|
- List<FaceInfo> faceInfoList1 = new ArrayList<>();
|
|
|
- errorCode = faceEngine.detectFaces(imageInfoEx, DetectModel.ASF_DETECT_MODEL_RGB, faceInfoList1);
|
|
|
-
|
|
|
- FunctionConfiguration fun = new FunctionConfiguration();
|
|
|
- fun.setSupportAge(true);
|
|
|
- errorCode = faceEngine.process(imageInfoEx, faceInfoList1, functionConfiguration);
|
|
|
- List<AgeInfo> ageInfoList1 = new ArrayList<>();
|
|
|
- int age = faceEngine.getAge(ageInfoList1);
|
|
|
- System.out.println("年龄:" + ageInfoList1.get(0).getAge());
|
|
|
-
|
|
|
- FaceFeature feature = new FaceFeature();
|
|
|
- errorCode = faceEngine.extractFaceFeature(imageInfoEx, faceInfoList1.get(0), feature);
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+// for(User u : userList){
|
|
|
+// try {
|
|
|
+// Field[] fields = u.getClass().getDeclaredFields();
|
|
|
+// if (fields.length > 0) {
|
|
|
+// Field lastField = fields[fields.length - 1];
|
|
|
+// lastField.setAccessible(true);
|
|
|
+// list.add((String) lastField.get(u));
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ list.add("D:\\javatext\\Zg5\\week1\\nekomimi\\images\\peixiuyurenlian.jpg");
|
|
|
+ list.add("D:\\javatext\\Zg5\\week1\\nekomimi\\images\\jincongrenlian.jpg");
|
|
|
+
|
|
|
+ Double ddd = 0.0;
|
|
|
+ for(String s:list){
|
|
|
+ ImageInfo imageInfo2 = getRGBData(new File(s));
|
|
|
+ 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());
|
|
|
+ if(faceSimilar.getScore()>=0.8){
|
|
|
+ ddd= Double.valueOf(faceSimilar.getScore());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ System.err.println(ddd);
|
|
|
+
|
|
|
+// //人脸检测2
|
|
|
+// ImageInfo imageInfo2 = getRGBData(new File("D:\\javatext\\Zg5\\week1\\nekomimi\\images\\peixiuyurenlian.jpg"));
|
|
|
+//// ImageInfo imageInfo2 = getRGBData(new File("D:\\计算机\\536d6c8a02947d1128642d34c009d06.jpg"));
|
|
|
+// 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.setLivenessParam(0.5f, 0.7f);
|
|
|
+// //人脸属性检测
|
|
|
+// FunctionConfiguration configuration = new FunctionConfiguration();
|
|
|
+// configuration.setSupportAge(true);
|
|
|
+// configuration.setSupportFace3dAngle(true);
|
|
|
+// configuration.setSupportGender(true);
|
|
|
+// configuration.setSupportLiveness(true);
|
|
|
+// errorCode = faceEngine.process(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList, configuration);
|
|
|
+//
|
|
|
+//
|
|
|
+// //性别检测
|
|
|
+// List<GenderInfo> genderInfoList = new ArrayList<GenderInfo>();
|
|
|
+// errorCode = faceEngine.getGender(genderInfoList);
|
|
|
+// System.out.println("性别:" + genderInfoList.get(0).getGender());
|
|
|
+//
|
|
|
+// //年龄检测
|
|
|
+// List<AgeInfo> ageInfoList = new ArrayList<AgeInfo>();
|
|
|
+// errorCode = faceEngine.getAge(ageInfoList);
|
|
|
+// System.out.println("年龄:" + ageInfoList.get(0).getAge());
|
|
|
+//
|
|
|
+// //3D信息检测
|
|
|
+// List<Face3DAngle> face3DAngleList = new ArrayList<Face3DAngle>();
|
|
|
+// errorCode = faceEngine.getFace3DAngle(face3DAngleList);
|
|
|
+// System.out.println("3D角度:" + face3DAngleList.get(0).getPitch() + "," + face3DAngleList.get(0).getRoll() + "," + face3DAngleList.get(0).getYaw());
|
|
|
+//
|
|
|
+// //活体检测
|
|
|
+// List<LivenessInfo> livenessInfoList = new ArrayList<LivenessInfo>();
|
|
|
+// errorCode = faceEngine.getLiveness(livenessInfoList);
|
|
|
+// System.out.println("活体:" + livenessInfoList.get(0).getLiveness());
|
|
|
+//
|
|
|
+//
|
|
|
+// //IR属性处理
|
|
|
+// ImageInfo imageInfoGray = getGrayData(new File("D:\\计算机\\b9e4b8a58d3db22741714f8ad24d175.jpg"));
|
|
|
+// List<FaceInfo> faceInfoListGray = new ArrayList<FaceInfo>();
|
|
|
+// errorCode = faceEngine.detectFaces(imageInfoGray.getImageData(), imageInfoGray.getWidth(), imageInfoGray.getHeight(), imageInfoGray.getImageFormat(), faceInfoListGray);
|
|
|
+//
|
|
|
+// FunctionConfiguration configuration2 = new FunctionConfiguration();
|
|
|
+// configuration2.setSupportIRLiveness(true);
|
|
|
+// errorCode = faceEngine.processIr(imageInfoGray.getImageData(), imageInfoGray.getWidth(), imageInfoGray.getHeight(), imageInfoGray.getImageFormat(), faceInfoListGray, configuration2);
|
|
|
+// //IR活体检测
|
|
|
+// List<IrLivenessInfo> irLivenessInfo = new ArrayList<>();
|
|
|
+// errorCode = faceEngine.getLivenessIr(irLivenessInfo);
|
|
|
+// System.out.println("IR活体:" + irLivenessInfo.get(0).getLiveness());
|
|
|
+//
|
|
|
+// ImageInfoEx imageInfoEx = new ImageInfoEx();
|
|
|
+// imageInfoEx.setHeight(imageInfo.getHeight());
|
|
|
+// imageInfoEx.setWidth(imageInfo.getWidth());
|
|
|
+// imageInfoEx.setImageFormat(imageInfo.getImageFormat());
|
|
|
+// imageInfoEx.setImageDataPlanes(new byte[][]{imageInfo.getImageData()});
|
|
|
+// imageInfoEx.setImageStrides(new int[]{imageInfo.getWidth() * 3});
|
|
|
+// List<FaceInfo> faceInfoList1 = new ArrayList<>();
|
|
|
+// errorCode = faceEngine.detectFaces(imageInfoEx, DetectModel.ASF_DETECT_MODEL_RGB, faceInfoList1);
|
|
|
+//
|
|
|
+// FunctionConfiguration fun = new FunctionConfiguration();
|
|
|
+// fun.setSupportAge(true);
|
|
|
+// errorCode = faceEngine.process(imageInfoEx, faceInfoList1, functionConfiguration);
|
|
|
+// List<AgeInfo> ageInfoList1 = new ArrayList<>();
|
|
|
+// int age = faceEngine.getAge(ageInfoList1);
|
|
|
+// System.out.println("年龄:" + ageInfoList1.get(0).getAge());
|
|
|
+//
|
|
|
+// FaceFeature feature = new FaceFeature();
|
|
|
+// errorCode = faceEngine.extractFaceFeature(imageInfoEx, faceInfoList1.get(0), feature);
|
|
|
|
|
|
|
|
|
//引擎卸载
|