You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//初始化人脸检测器
FaceDetector detector = new FaceDetector();
//图片地址
String path="/test.jpg";
//人脸检测
List<FaceRect> res = detector.detect(path);
//输出检测结果
System.out.println(res);
除了上述使用图片地址检测,为方便使用,还提供了以下几种重载
//根据图片类检测
public List<FaceRect> detect(BufferedImage img);
//根据输入流检测
public List<FaceRect> detect(InputStream input);
//根据图片字节码检测
public List<FaceRect> detect(byte[] bytes);
多线程人脸检测,与单线程使用方式相同,人脸检测器初始化的不同,也有以上的几种重载方式
//初始化人脸检测器,指定线程数量
FaceDetectorAsync detector = new FaceDetectorAsync(2);
//图片地址
String path="/test.jpg";
//人脸检测
List<FaceRect> res = detector.detect(path);
//输出检测结果
System.out.println(res);
单线程提取人脸特征,重载同以上
//初始化人脸检测器
FaceRecognizer recognizer = new FaceRecognizer();
//图片路径
String path="/test.jpg";
//提取特征
List<FaceFeature> res = recognizer.feature(path);
//输出结果
System.out.println(res);
多线程提取人脸特征,重载同以上
//初始化人脸检测器,指定线程数量
FaceRecognizerAsync recognizer = new FaceRecognizerAsync(2);
//图片路径
String path="/test.jpg";
//提取特征
List<FaceFeature> res = recognizer.feature(path);
//输出结果
System.out.println(res);