基于中科视拓的seetaface6封装的免费人脸识别项目后端接口
shentao
2025-09-22 6474cdddb5933d64efdf0207614be2596a7a3600
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.code2roc.fastface.config;
 
import com.seeta.pool.SeetaConfSetting;
import com.seeta.proxy.FaceDetectorProxy;
import com.seeta.proxy.FaceLandmarkerProxy;
import com.seeta.proxy.FaceRecognizerProxy;
import com.seeta.sdk.SeetaDevice;
import com.seeta.sdk.SeetaModelSetting;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 
import java.io.File;
import java.io.FileNotFoundException;
import java.nio.file.Path;
import java.nio.file.Paths;
 
@Configuration
public class FaceConfig {
    @Value("${face.modelPath}")
    private String modelPath;
 
    @Bean
    public FaceDetectorProxy faceDetector() throws FileNotFoundException {
        Path tempDir = Paths.get(System.getProperty("user.dir"), modelPath);
        SeetaConfSetting detectorPoolSetting = new SeetaConfSetting(
                new SeetaModelSetting(0, new String[]{tempDir + File.separator + "face_detector.csta"}, SeetaDevice.SEETA_DEVICE_CPU));
        FaceDetectorProxy faceDetectorProxy = new FaceDetectorProxy(detectorPoolSetting);
        return faceDetectorProxy;
    }
 
    @Bean
    public FaceRecognizerProxy faceRecognizer() throws FileNotFoundException {
        Path tempDir = Paths.get(System.getProperty("user.dir"), modelPath);
        SeetaConfSetting detectorPoolSetting = new SeetaConfSetting(
                new SeetaModelSetting(0, new String[]{tempDir + File.separator + "face_recognizer_light.csta"}, SeetaDevice.SEETA_DEVICE_CPU));
        FaceRecognizerProxy faceRecognizerProxy = new FaceRecognizerProxy(detectorPoolSetting);
        return faceRecognizerProxy;
    }
 
    @Bean
    public FaceLandmarkerProxy faceLandmarker() throws FileNotFoundException {
        Path tempDir = Paths.get(System.getProperty("user.dir"), modelPath);
        SeetaConfSetting detectorPoolSetting = new SeetaConfSetting(
                new SeetaModelSetting(0, new String[]{tempDir + File.separator + "face_landmarker_pts5.csta"}, SeetaDevice.SEETA_DEVICE_CPU));
        FaceLandmarkerProxy faceLandmarkerProxy = new FaceLandmarkerProxy(detectorPoolSetting);
        return faceLandmarkerProxy;
    }
}