mirror of
https://gitee.com/open-visual/face-search.git
synced 2025-07-25 19:41:42 +08:00
update: 更新测试用例
This commit is contained in:
parent
a4fb5298de
commit
83ed249c14
@ -1,5 +1,6 @@
|
||||
package com.visual.face.search.core.test.extract;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.visual.face.search.core.base.*;
|
||||
import com.visual.face.search.core.domain.ExtParam;
|
||||
import com.visual.face.search.core.domain.FaceImage;
|
||||
@ -29,8 +30,9 @@ public class FaceFeatureExtractTest extends BaseTest {
|
||||
private static String modelArcPath = "face-search-core/src/main/resources/model/onnx/recognition_face_arc/glint360k_cosface_r18_fp16_0.1.onnx";
|
||||
private static String modelArrPath = "face-search-core/src/main/resources/model/onnx/attribute_gender_age/insight_gender_age.onnx";
|
||||
|
||||
// private static String imagePath = "face-search-core/src/test/resources/images/faces";
|
||||
private static String imagePath = "face-search-core/src/test/resources/images/faces/debug/debug_0001.jpg";
|
||||
private static String imagePath = "face-search-core/src/test/resources/images/faces";
|
||||
// private static String imagePath = "face-search-core/src/test/resources/images/faces/debug/debug_0001.jpg";
|
||||
// private static String imagePath = "face-search-core/src/test/resources/images/faces/rotate/rotate_0002.jpg";
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
@ -44,7 +46,7 @@ public class FaceFeatureExtractTest extends BaseTest {
|
||||
FaceAttribute insightFaceAttribute = new InsightAttributeDetection(modelArrPath, 1);
|
||||
|
||||
FaceFeatureExtractor extractor = new FaceFeatureExtractorImpl(
|
||||
pcnNetworkFaceDetection, insightScrfdFaceDetection, insightCoordFaceKeyPoint,
|
||||
insightScrfdFaceDetection, pcnNetworkFaceDetection, insightCoordFaceKeyPoint,
|
||||
simple005pFaceAlignment, insightArcFaceRecognition, insightFaceAttribute);
|
||||
for(String fileName : map.keySet()){
|
||||
String imageFilePath = map.get(fileName);
|
||||
@ -56,7 +58,8 @@ public class FaceFeatureExtractTest extends BaseTest {
|
||||
.setTopK(20)
|
||||
.setScoreTh(0)
|
||||
.setIouTh(0);
|
||||
FaceImage faceImage = extractor.extract(ImageMat.fromCVMat(image), extParam, null);
|
||||
Map<String, Object> params = new JSONObject().fluentPut(InsightScrfdFaceDetection.scrfdFaceNeedCheckFaceAngleParamKey, true);
|
||||
FaceImage faceImage = extractor.extract(ImageMat.fromCVMat(image), extParam, params);
|
||||
List<FaceInfo> faceInfos = faceImage.faceInfos();
|
||||
long e = System.currentTimeMillis();
|
||||
System.out.println("fileName="+fileName+",\tcost="+(e-s)+",\t"+faceInfos);
|
||||
@ -67,7 +70,7 @@ public class FaceFeatureExtractTest extends BaseTest {
|
||||
Imgproc.line(image, new Point(box.rightTop.x, box.rightTop.y), new Point(box.rightBottom.x, box.rightBottom.y), new Scalar(255,0,0), 1);
|
||||
Imgproc.line(image, new Point(box.rightBottom.x, box.rightBottom.y), new Point(box.leftBottom.x, box.leftBottom.y), new Scalar(255,0,0), 1);
|
||||
Imgproc.line(image, new Point(box.leftBottom.x, box.leftBottom.y), new Point(box.leftTop.x, box.leftTop.y), new Scalar(255,0,0), 1);
|
||||
Imgproc.putText(image, String.valueOf(faceInfo.angle), new Point(box.leftTop.x, box.leftTop.y), Imgproc.FONT_HERSHEY_PLAIN, 1, new Scalar(0,0,255));
|
||||
Imgproc.putText(image, String.valueOf(faceInfo.angle), new Point(box.leftTop.x, box.leftTop.y+15), Imgproc.FONT_HERSHEY_PLAIN, 1, new Scalar(0,0,255));
|
||||
// Imgproc.rectangle(image, new Point(faceInfo.box.x1(), faceInfo.box.y1()), new Point(faceInfo.box.x2(), faceInfo.box.y2()), new Scalar(255,0,255));
|
||||
|
||||
FaceInfo.FaceBox box1 = faceInfo.rotateFaceBox();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.visual.face.search.core.test.models;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.visual.face.search.core.domain.FaceInfo;
|
||||
import com.visual.face.search.core.domain.ImageMat;
|
||||
import com.visual.face.search.core.models.InsightScrfdFaceDetection;
|
||||
@ -11,15 +12,16 @@ import org.opencv.highgui.HighGui;
|
||||
import org.opencv.imgcodecs.Imgcodecs;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class InsightScrfdFaceDetectionTest extends BaseTest {
|
||||
private static String modelPath = "face-search-core/src/main/resources/model/onnx/detection_face_scrfd/scrfd_500m_bnkps.onnx";
|
||||
|
||||
private static String imagePath = "face-search-core/src/test/resources/images/faces";
|
||||
// private static String imagePath = "face-search-core/src/test/resources/images/faces";
|
||||
private static String imagePath = "face-search-core/src/test/resources/images/faces/rotate/rotate_0001.jpg";
|
||||
// private static String imagePath = "face-search-core/src/test/resources/images/faces/rotate";
|
||||
// private static String imagePath = "face-search-core/src/test/resources/images/faces/debug";
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
@ -31,7 +33,9 @@ public class InsightScrfdFaceDetectionTest extends BaseTest {
|
||||
System.out.println(imageFilePath);
|
||||
Mat image = Imgcodecs.imread(imageFilePath);
|
||||
long s = System.currentTimeMillis();
|
||||
List<FaceInfo> faceInfos = infer.inference(ImageMat.fromCVMat(image), 0.5f, 0.7f, null);
|
||||
Map<String, Object> params = new JSONObject().fluentPut(InsightScrfdFaceDetection.scrfdFaceNeedCheckFaceAngleParamKey, true);
|
||||
|
||||
List<FaceInfo> faceInfos = infer.inference(ImageMat.fromCVMat(image), 0.48f, 0.7f, params);
|
||||
long e = System.currentTimeMillis();
|
||||
if(faceInfos.size() > 0){
|
||||
System.out.println("fileName="+fileName+",\tcost="+(e-s)+",\t"+faceInfos.get(0).score);
|
||||
@ -39,10 +43,20 @@ public class InsightScrfdFaceDetectionTest extends BaseTest {
|
||||
System.out.println("fileName="+fileName+",\tcost="+(e-s)+",\t"+faceInfos);
|
||||
}
|
||||
|
||||
//对坐标进行调整
|
||||
for(FaceInfo faceInfo : faceInfos){
|
||||
Imgproc.rectangle(image, new Point(faceInfo.box.x1(), faceInfo.box.y1()), new Point(faceInfo.box.x2(), faceInfo.box.y2()), new Scalar(0,0,255));
|
||||
FaceInfo.FaceBox box = faceInfo.rotateFaceBox();
|
||||
Imgproc.circle(image, new Point(box.leftTop.x, box.leftTop.y), 3, new Scalar(0,0,255), -1);
|
||||
Imgproc.circle(image, new Point(box.rightBottom.x, box.rightBottom.y), 3, new Scalar(0,0,255), -1);
|
||||
Imgproc.line(image, new Point(box.leftTop.x, box.leftTop.y), new Point(box.rightTop.x, box.rightTop.y), new Scalar(0,0,255), 1);
|
||||
Imgproc.line(image, new Point(box.rightTop.x, box.rightTop.y), new Point(box.rightBottom.x, box.rightBottom.y), new Scalar(255,0,0), 1);
|
||||
Imgproc.line(image, new Point(box.rightBottom.x, box.rightBottom.y), new Point(box.leftBottom.x, box.leftBottom.y), new Scalar(255,0,0), 1);
|
||||
Imgproc.line(image, new Point(box.leftBottom.x, box.leftBottom.y), new Point(box.leftTop.x, box.leftTop.y), new Scalar(255,0,0), 1);
|
||||
Imgproc.putText(image, String.valueOf(faceInfo.angle), new Point(box.leftTop.x, box.leftTop.y), Imgproc.FONT_HERSHEY_PLAIN, 1, new Scalar(0,0,255));
|
||||
|
||||
FaceInfo.Points points = faceInfo.points;
|
||||
int pointNum = 1;
|
||||
for(FaceInfo.Point keyPoint : faceInfo.points){
|
||||
for(FaceInfo.Point keyPoint : points){
|
||||
Imgproc.circle(image, new Point(keyPoint.x, keyPoint.y), 3, new Scalar(0,0,255), -1);
|
||||
Imgproc.putText(image, String.valueOf(pointNum), new Point(keyPoint.x+1, keyPoint.y), Imgproc.FONT_HERSHEY_PLAIN, 1, new Scalar(255,0,0));
|
||||
pointNum ++ ;
|
||||
|
@ -21,7 +21,8 @@ public class PcnNetworkFaceDetectionTest extends BaseTest {
|
||||
private static String model2Path = "face-search-core/src/main/resources/model/onnx/detection_face_pcn/pcn2_sd.onnx";
|
||||
private static String model3Path = "face-search-core/src/main/resources/model/onnx/detection_face_pcn/pcn3_sd.onnx";
|
||||
|
||||
private static String imagePath = "face-search-core/src/test/resources/images/faces";
|
||||
// private static String imagePath = "face-search-core/src/test/resources/images/faces";
|
||||
private static String imagePath = "face-search-core/src/test/resources/images/faces/rotate/rotate_0001.jpg";
|
||||
// private static String imagePath = "face-search-core/src/test/resources/images/faces/rotate";
|
||||
// private static String imagePath = "face-search-core/src/test/resources/images/faces/debug";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user