001// 002// This file is auto-generated. Please don't modify it! 003// 004package org.opencv.objdetect; 005 006import org.opencv.core.Mat; 007import org.opencv.objdetect.FaceRecognizerSF; 008 009// C++: class FaceRecognizerSF 010/** 011 * DNN-based face recognizer 012 * 013 * model download link: https://github.com/opencv/opencv_zoo/tree/master/models/face_recognition_sface 014 */ 015public class FaceRecognizerSF { 016 017 protected final long nativeObj; 018 protected FaceRecognizerSF(long addr) { nativeObj = addr; } 019 020 public long getNativeObjAddr() { return nativeObj; } 021 022 // internal usage only 023 public static FaceRecognizerSF __fromPtr__(long addr) { return new FaceRecognizerSF(addr); } 024 025 // C++: enum DisType (cv.FaceRecognizerSF.DisType) 026 public static final int 027 FR_COSINE = 0, 028 FR_NORM_L2 = 1; 029 030 031 // 032 // C++: void cv::FaceRecognizerSF::alignCrop(Mat src_img, Mat face_box, Mat& aligned_img) 033 // 034 035 /** 036 * Aligning image to put face on the standard position 037 * @param src_img input image 038 * @param face_box the detection result used for indicate face in input image 039 * @param aligned_img output aligned image 040 */ 041 public void alignCrop(Mat src_img, Mat face_box, Mat aligned_img) { 042 alignCrop_0(nativeObj, src_img.nativeObj, face_box.nativeObj, aligned_img.nativeObj); 043 } 044 045 046 // 047 // C++: void cv::FaceRecognizerSF::feature(Mat aligned_img, Mat& face_feature) 048 // 049 050 /** 051 * Extracting face feature from aligned image 052 * @param aligned_img input aligned image 053 * @param face_feature output face feature 054 */ 055 public void feature(Mat aligned_img, Mat face_feature) { 056 feature_0(nativeObj, aligned_img.nativeObj, face_feature.nativeObj); 057 } 058 059 060 // 061 // C++: double cv::FaceRecognizerSF::match(Mat face_feature1, Mat face_feature2, int dis_type = FaceRecognizerSF::FR_COSINE) 062 // 063 064 /** 065 * Calculating the distance between two face features 066 * @param face_feature1 the first input feature 067 * @param face_feature2 the second input feature of the same size and the same type as face_feature1 068 * @param dis_type defining the similarity with optional values "FR_OSINE" or "FR_NORM_L2" 069 * @return automatically generated 070 */ 071 public double match(Mat face_feature1, Mat face_feature2, int dis_type) { 072 return match_0(nativeObj, face_feature1.nativeObj, face_feature2.nativeObj, dis_type); 073 } 074 075 /** 076 * Calculating the distance between two face features 077 * @param face_feature1 the first input feature 078 * @param face_feature2 the second input feature of the same size and the same type as face_feature1 079 * @return automatically generated 080 */ 081 public double match(Mat face_feature1, Mat face_feature2) { 082 return match_1(nativeObj, face_feature1.nativeObj, face_feature2.nativeObj); 083 } 084 085 086 // 087 // C++: static Ptr_FaceRecognizerSF cv::FaceRecognizerSF::create(String model, String config, int backend_id = 0, int target_id = 0) 088 // 089 090 /** 091 * Creates an instance of this class with given parameters 092 * @param model the path of the onnx model used for face recognition 093 * @param config the path to the config file for compability, which is not requested for ONNX models 094 * @param backend_id the id of backend 095 * @param target_id the id of target device 096 * @return automatically generated 097 */ 098 public static FaceRecognizerSF create(String model, String config, int backend_id, int target_id) { 099 return FaceRecognizerSF.__fromPtr__(create_0(model, config, backend_id, target_id)); 100 } 101 102 /** 103 * Creates an instance of this class with given parameters 104 * @param model the path of the onnx model used for face recognition 105 * @param config the path to the config file for compability, which is not requested for ONNX models 106 * @param backend_id the id of backend 107 * @return automatically generated 108 */ 109 public static FaceRecognizerSF create(String model, String config, int backend_id) { 110 return FaceRecognizerSF.__fromPtr__(create_1(model, config, backend_id)); 111 } 112 113 /** 114 * Creates an instance of this class with given parameters 115 * @param model the path of the onnx model used for face recognition 116 * @param config the path to the config file for compability, which is not requested for ONNX models 117 * @return automatically generated 118 */ 119 public static FaceRecognizerSF create(String model, String config) { 120 return FaceRecognizerSF.__fromPtr__(create_2(model, config)); 121 } 122 123 124 @Override 125 protected void finalize() throws Throwable { 126 delete(nativeObj); 127 } 128 129 130 131 // C++: void cv::FaceRecognizerSF::alignCrop(Mat src_img, Mat face_box, Mat& aligned_img) 132 private static native void alignCrop_0(long nativeObj, long src_img_nativeObj, long face_box_nativeObj, long aligned_img_nativeObj); 133 134 // C++: void cv::FaceRecognizerSF::feature(Mat aligned_img, Mat& face_feature) 135 private static native void feature_0(long nativeObj, long aligned_img_nativeObj, long face_feature_nativeObj); 136 137 // C++: double cv::FaceRecognizerSF::match(Mat face_feature1, Mat face_feature2, int dis_type = FaceRecognizerSF::FR_COSINE) 138 private static native double match_0(long nativeObj, long face_feature1_nativeObj, long face_feature2_nativeObj, int dis_type); 139 private static native double match_1(long nativeObj, long face_feature1_nativeObj, long face_feature2_nativeObj); 140 141 // C++: static Ptr_FaceRecognizerSF cv::FaceRecognizerSF::create(String model, String config, int backend_id = 0, int target_id = 0) 142 private static native long create_0(String model, String config, int backend_id, int target_id); 143 private static native long create_1(String model, String config, int backend_id); 144 private static native long create_2(String model, String config); 145 146 // native support for java finalize() 147 private static native void delete(long nativeObj); 148 149}