/// <summary> /// Release the unmanaged memory associated with this object. /// </summary> protected override void DisposeObject() { if (_ptr != IntPtr.Zero) { FaceInvoke.cveFacemarkLBFParamsRelease(ref _ptr); } }
/// <summary> /// Release all the unmanaged memory associated with this Facemark /// </summary> protected override void DisposeObject() { if (_ptr != IntPtr.Zero) { FaceInvoke.cveFacemarkAAMRelease(ref _ptr, ref _sharedPtr); } }
/// <summary> /// train it on positive features compute the mace filter: h = D(-1) * X * (X(+) * D(-1) * X)(-1) * C also calculate a minimal threshold for this class, the smallest self-similarity from the train images /// </summary> /// <param name="images">A VectorOfMat with the train images</param> public void Train(IInputArrayOfArrays images) { using (InputArray iaImages = images.GetInputArray()) { FaceInvoke.cveMaceTrain(_ptr, iaImages); } }
/// <summary> /// optionally encrypt images with random convolution /// </summary> /// <param name="passphrase">a crc64 random seed will get generated from this</param> public void Salt(String passphrase) { using (CvString csPassphrase = new CvString(passphrase)) { FaceInvoke.cveMaceSalt(_ptr, csPassphrase); } }
/// <summary> /// correlate query img and threshold to min class value /// </summary> /// <param name="query">a Mat with query image</param> /// <returns>True if the query is the same</returns> public bool Same(IInputArray query) { using (InputArray iaQuery = query.GetInputArray()) { return(FaceInvoke.cveMaceSame(_ptr, iaQuery)); } }
/// <summary> /// Sets string info for the specified model's label. /// </summary> /// <param name="label">The label</param> /// <param name="strInfo">The string info</param> /// <remarks>The string info is replaced by the provided value if it was set before for the specified label.</remarks> public void SetLabelInfo(int label, String strInfo) { using (CvString csStrInfo = new CvString(strInfo)) { FaceInvoke.cveFaceRecognizerSetLabelInfo(_faceRecognizerPtr, label, csStrInfo); } }
/// <summary> /// Gets string information by label. If an unknown label id is provided or there is no label information associated with the specified label id the method returns an empty string. /// </summary> /// <param name="label">The label</param> /// <returns>The string associated with this label.</returns> public String GetLabelInfo(int label) { using (CvString csStrInfo = new CvString()) { FaceInvoke.cveFaceRecognizerGetLabelInfo(_faceRecognizerPtr, label, csStrInfo); return(csStrInfo.ToString()); } }
/// <summary> /// Release the unmanaged memory associated with this FisherFaceRecognizer /// </summary> protected override void DisposeObject() { if (_sharedPtr == IntPtr.Zero) { FaceInvoke.cveLBPHFaceRecognizerRelease(ref _sharedPtr); } base.DisposeObject(); }
/// <summary> /// Release the unmanaged memory associated with this BIF /// </summary> protected override void DisposeObject() { if (_sharedPtr != IntPtr.Zero) { FaceInvoke.cveBIFRelease(ref _sharedPtr); _ptr = IntPtr.Zero; } }
/// <summary> /// Create a LBPH face recognizer /// </summary> /// <param name="radius">Radius</param> /// <param name="neighbors">Neighbors</param> /// <param name="gridX">Grid X</param> /// <param name="gridY">Grid Y</param> /// <param name="threshold">The distance threshold</param> public LBPHFaceRecognizer(int radius = 1, int neighbors = 8, int gridX = 8, int gridY = 8, double threshold = Double.MaxValue) { _ptr = FaceInvoke.cveLBPHFaceRecognizerCreate( radius, neighbors, gridX, gridY, threshold, ref _faceRecognizerPtr, ref _sharedPtr); }
/// <summary> /// Predict the label of the image /// </summary> /// <param name="image">The image where prediction will be based on</param> /// <returns>The prediction label</returns> public PredictionResult Predict(IInputArray image) { int label = -1; double distance = -1; using (InputArray iaImage = image.GetInputArray()) FaceInvoke.cveFaceRecognizerPredict(_faceRecognizerPtr, iaImage, ref label, ref distance); return(new PredictionResult() { Label = label, Distance = distance }); }
/// <summary> /// Updates a FaceRecognizer with given data and associated labels. /// </summary> /// <param name="images">The training images, that means the faces you want to learn. The data has to be given as a VectorOfMat.</param> /// <param name="labels">The labels corresponding to the images</param> public void Update(IInputArray images, IInputArray labels) { using (InputArray iaImages = images.GetInputArray()) using (InputArray iaLabels = labels.GetInputArray()) FaceInvoke.cveFaceRecognizerUpdate(_faceRecognizerPtr, iaImages, iaLabels); }
/// <summary> /// Create a FisherFaceRecognizer /// </summary> /// <param name="numComponents">The number of components</param> /// <param name="threshold">The distance threshold</param> public FisherFaceRecognizer(int numComponents = 0, double threshold = double.MaxValue) { _ptr = FaceInvoke.cveFisherFaceRecognizerCreate(numComponents, threshold, ref _faceRecognizerPtr, ref _basicFaceRecognizerPtr, ref _sharedPtr); }
/// <summary> /// Computes features by input image. /// </summary> /// <param name="image">Input image (CV_32FC1)</param> /// <param name="features">Feature vector (CV_32FC1)</param> public void Compute(IInputArray image, IOutputArray features) { using (InputArray iaImage = image.GetInputArray()) using (OutputArray oaFeatures = features.GetOutputArray()) FaceInvoke.cveBIFCompute(_ptr, iaImage, oaFeatures); }
/// <summary> /// Create an instance of bio-inspired features /// </summary> /// <param name="numBands">The number of filter bands used for computing BIF.</param> /// <param name="numRotations">The number of image rotations.</param> public BIF(int numBands, int numRotations) { _ptr = FaceInvoke.cveBIFCreate(numBands, numRotations, ref _sharedPtr); }
/// <summary> /// Release the unmanaged memory associated with this BIF /// </summary> protected override void DisposeObject() { FaceInvoke.cveBIFRelease(ref _ptr); }
/// <summary> /// Load the FaceRecognizer from the file /// </summary> /// <param name="fileName">The file where the FaceRecognizer will be loaded from</param> public void Read(String fileName) { using (CvString s = new CvString(fileName)) FaceInvoke.cveFaceRecognizerRead(_ptr, s); }
/// <summary> /// Create an instance of FacemarkAAM model /// </summary> /// <param name="parameters">The model parameters</param> public FacemarkAAM(FacemarkAAMParams parameters) { _ptr = FaceInvoke.cveFacemarkAAMCreate(parameters, ref _facemarkPtr, ref _algorithmPtr, ref _sharedPtr); }
/// <summary> /// Release the unmanaged memory associated with this FaceRecognizer /// </summary> protected override void DisposeObject() { FaceInvoke.cveFaceRecognizerRelease(ref _ptr, ref _sharedPtr); }
/// <summary> /// Create an EigenFaceRecognizer /// </summary> /// <param name="numComponents">The number of components</param> /// <param name="threshold">The distance threshold</param> public EigenFaceRecognizer(int numComponents = 0, double threshold = double.MaxValue) { _ptr = FaceInvoke.cveEigenFaceRecognizerCreate(numComponents, threshold, ref _sharedPtr); }
/// <summary> /// Create an instance of the FacemarkLBF model /// </summary> /// <param name="parameters">The model parameters</param> public FacemarkLBF(FacemarkLBFParams parameters) { _ptr = FaceInvoke.cveFacemarkLBFCreate(parameters, ref _facemarkPtr, ref _algorithmPtr); }
/// <summary> /// Create a new MACE object /// </summary> /// <param name="imgSize">images will get resized to this (should be an even number)</param> public MACE(int imgSize) { _ptr = FaceInvoke.cveMaceCreate(imgSize, ref _sharedPtr); }
/// <summary> /// Save the FaceRecognizer to a file /// </summary> /// <param name="fileName">The file name to be saved to</param> public void Write(String fileName) { using (CvString s = new CvString(fileName)) FaceInvoke.cveFaceRecognizerWrite(_faceRecognizerPtr, s); }
/// <summary> /// Create the paramaters with the default values. /// </summary> public FacemarkAAMParams() { _ptr = FaceInvoke.cveFacemarkAAMParamsCreate(); }
/// <summary> /// Create an instance of bio-inspired features /// </summary> /// <param name="numBands">The number of filter bands used for computing BIF.</param> /// <param name="numRotations">The number of image rotations.</param> public BIF(int numBands, int numRotations) { _ptr = FaceInvoke.cveBIFCreate(numBands, numRotations); }
/// <summary> /// Create a FisherFaceRecognizer /// </summary> /// <param name="numComponents">The number of components</param> /// <param name="threshold">The distance threshold</param> public FisherFaceRecognizer(int numComponents = 0, double threshold = double.MaxValue) { _ptr = FaceInvoke.cveFisherFaceRecognizerCreate(numComponents, threshold); }
/// <summary> /// Train the face recognizer with the specific images and labels /// </summary> /// <param name="images">The images used in the training. This can be a VectorOfMat</param> /// <param name="labels">The labels of the images. This can be a VectorOfInt</param> public void Train(IInputArray images, IInputArray labels) { using (InputArray iaImage = images.GetInputArray()) using (InputArray iaLabels = labels.GetInputArray()) FaceInvoke.cveFaceRecognizerTrain(_faceRecognizerPtr, iaImage, iaLabels); }