请问有人用java实现过opencv的sface的人脸检测功能吗,java中的alignCrop应该怎样使用。
我本地启动报错如下
java+sface进行人脸特征提取
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- Y0220Y 2023-06-28 14:28关注
public static void main(String[] args) { // 1.初始化opencv initOpenCV(); // 3.读取图片 Mat imageA = Imgcodecs.imread("C:/Users/y1793/Desktop/1f48e0d3dbb39e3d7e063b321df6c3c.jpg"); Mat imageB = Imgcodecs.imread("C:/Users/y1793/Desktop/1f48e0d3dbb39e3d7e063b321df6c3c.jpg"); // 人脸识别 FaceDetectorYN faceDetectorYN = FaceDetectorYN.create("C:/Users/y1793/Downloads/face_detection_yunet_2022mar.onnx", "", new Size(), score_thresh, nms_thresh, top_k); Mat faceA = new Mat(); faceDetectorYN.setInputSize(new Size(imageA.width(), imageA.height())); faceDetectorYN.detect(imageA, faceA); Mat faceB = new Mat(); faceDetectorYN.setInputSize(new Size(imageB.width(), imageB.height())); faceDetectorYN.detect(imageB, faceB); // 人脸预处理 FaceRecognizerSF faceRecognizerSF = FaceRecognizerSF.create("C:/Users/y1793/Downloads/face_recognition_sface_2021dec.onnx", ""); Mat alignFaceA = new Mat(); faceRecognizerSF.alignCrop(imageA, faceA, alignFaceA); Mat alignFaceB = new Mat(); faceRecognizerSF.alignCrop(imageB, faceB, alignFaceB); // 人脸特征提取 Mat featureA = new Mat(); faceRecognizerSF.feature(alignFaceA, featureA); Mat featureB = new Mat(); faceRecognizerSF.feature(alignFaceB, featureB); // 人脸识别 double match1 = faceRecognizerSF.match(featureA, featureB, FaceRecognizerSF.FR_COSINE); double match2 = faceRecognizerSF.match(featureA, featureB, FaceRecognizerSF.FR_NORM_L2); System.out.println(match1); System.out.println(match2); }
解决 无用评论 打赏 举报
悬赏问题
- ¥15 360浏览器m2的这个值
- ¥15 国内有哪些厂商做automlops的?
- ¥15 skynet pb mysql
- ¥15 笔记本外接显示器分辨率太低各种方法都用过了调不高
- ¥15 Redstone R0697-F00 D2020 交换机 OS
- ¥50 H5+js 动态数字画廊怎么做?
- ¥20 外向内全景图像拼接相关项目和论文咨询
- ¥20 请写个前端案例学习使用
- ¥15 FFmpeg中G.711转AAC报错:[aac @ 0000014f803ab640] Input contains (near) NaN/+-Inf
- ¥15 关于#python#的问题,请各位专家解答!