Beispiel #1
0
 /*
  * /// <summary>
  * /// Set a user defined face detector for the Facemark algorithm.
  * /// </summary>
  * /// <param name="facemark">The facemark object</param>
  * /// <param name="faceDetect">The user defined face detector function</param>
  * /// <returns>True if sucessfull.</returns>
  * public static bool SetFaceDetector(this IFacemark facemark, FaceDetectNative faceDetect)
  * {
  *  return cveFacemarkSetFaceDetector(facemark.FacemarkPtr, faceDetect);
  * }
  *
  * /// <summary>
  * /// A native face detect function to be used with the SetFaceDetector function
  * /// </summary>
  * /// <param name="input">Should be a native pointer of cv::_InputArray*</param>
  * /// <param name="output">Should be a native pointer of cv::_OutputArray*</param>
  * /// <returns>True if face found</returns>
  * [UnmanagedFunctionPointer(CvInvoke.CvCallingConvention)]
  * [return: MarshalAs(CvInvoke.BoolMarshalType)]
  * public delegate bool FaceDetectNative(IntPtr input, IntPtr output);
  *
  * [DllImport(CvInvoke.ExternLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
  * [return: MarshalAs(CvInvoke.BoolMarshalType)]
  * internal extern static bool cveFacemarkSetFaceDetector(IntPtr facemark, FaceDetectNative detector);
  */
 /// <summary>
 /// A function to load the trained model before the fitting process.
 /// </summary>
 /// <param name="facemark">The facemark object</param>
 /// <param name="model">A string represent the filename of a trained model.</param>
 public static void LoadModel(this IFacemark facemark, String model)
 {
     using (CvString cs = new CvString(model))
     {
         cveFacemarkLoadModel(facemark.FacemarkPtr, cs);
     }
 }
Beispiel #2
0
 /// <summary>
 /// Default face detector This function is mainly utilized by the implementation of a Facemark Algorithm.
 /// </summary>
 /// <param name="facemark">The facemark object</param>
 /// <param name="image">The input image to be processed.</param>
 /// <param name="faces">Output of the function which represent region of interest of the detected faces. Each face is stored in cv::Rect container.</param>
 /// <returns>True if success</returns>
 public static bool GetFaces(this IFacemark facemark, IInputArray image, IOutputArray faces)
 {
     using (InputArray iaImage = image.GetInputArray())
         using (OutputArray oaFaces = faces.GetOutputArray())
         {
             return(cveFacemarkGetFaces(facemark.FacemarkPtr, iaImage, oaFaces));
         }
 }
Beispiel #3
0
 /// <summary>
 /// Add one training sample to the trainer.
 /// </summary>
 /// <param name="facemark">The facemark object</param>
 /// <param name="image">Input image.</param>
 /// <param name="landmarks">The ground-truth of facial landmarks points corresponds to the image.</param>
 /// <returns></returns>
 public static bool AddTraningSample(this IFacemark facemark, IInputArray image, IInputArray landmarks)
 {
     using (InputArray iaImage = image.GetInputArray())
         using (InputArray iaLandmarks = landmarks.GetInputArray())
         {
             return(cveFacemarkAddTrainingSample(facemark.FacemarkPtr, iaImage, iaLandmarks));
         }
 }
Beispiel #4
0
        /*
         * /// <summary>
         * /// Default face detector This function is mainly utilized by the implementation of a Facemark Algorithm.
         * /// </summary>
         * /// <param name="facemark">The facemark object</param>
         * /// <param name="image">The input image to be processed.</param>
         * /// <param name="faces">Output of the function which represent region of interest of the detected faces. Each face is stored in cv::Rect container.</param>
         * /// <returns>True if success</returns>
         * public static bool GetFaces(this IFacemark facemark, IInputArray image, IOutputArray faces)
         * {
         *  using (InputArray iaImage = image.GetInputArray())
         *  using (OutputArray oaFaces = faces.GetOutputArray())
         *  {
         *      return cveFacemarkGetFaces(facemark.FacemarkPtr, iaImage, oaFaces);
         *  }
         * }
         * [DllImport(CvInvoke.ExternLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
         * [return: MarshalAs(CvInvoke.BoolMarshalType)]
         * internal extern static bool cveFacemarkGetFaces(IntPtr facemark, IntPtr image, IntPtr faces);
         */

        /// <summary>
        /// Trains a Facemark algorithm using the given dataset.
        /// </summary>
        /// <param name="facemark">The facemark object</param>
        /// <param name="image">Input image.</param>
        /// <param name="faces">Represent region of interest of the detected faces. Each face is stored in cv::Rect container.</param>
        /// <param name="landmarks">The detected landmark points for each faces.</param>
        /// <returns>True if successful</returns>
        public static bool Fit(this IFacemark facemark, IInputArray image, IInputArray faces, IInputOutputArray landmarks)
        {
            using (InputArray iaImage = image.GetInputArray())
                using (InputArray iaFaces = faces.GetInputArray())
                    using (InputOutputArray ioaLandmarks = landmarks.GetInputOutputArray())
                    {
                        return(cveFacemarkFit(facemark.FacemarkPtr, iaImage, iaFaces, ioaLandmarks));
                    }
        }
Beispiel #5
0
 /// <summary>
 /// Set a user defined face detector for the Facemark algorithm.
 /// </summary>
 /// <param name="facemark">The facemark object</param>
 /// <param name="faceDetect">The user defined face detector function</param>
 /// <returns>True if sucessfull.</returns>
 public static bool SetFaceDetector(this IFacemark facemark, FaceDetectNative faceDetect)
 {
     return(cveFacemarkSetFaceDetector(facemark.FacemarkPtr, faceDetect));
 }
Beispiel #6
0
 /// <summary>
 /// Trains a Facemark algorithm using the given dataset. Before the training process, training samples should be added to the trainer using AddTrainingSample function.
 /// </summary>
 /// <param name="facemark">The facemark object</param>
 public static void Training(this IFacemark facemark)
 {
     cveFacemarkTraining(facemark.FacemarkPtr);
 }