Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="radius">The radius used for building the Circular Local Binary Pattern. The greater the radius, the</param>
        /// <param name="neighbors">The number of sample points to build a Circular Local Binary Pattern from.
        /// An appropriate value is to use `8` sample points.Keep in mind: the more sample points you include, the higher the computational cost.</param>
        /// <param name="gridX">The number of cells in the horizontal direction, 8 is a common value used in publications.
        /// The more cells, the finer the grid, the higher the dimensionality of the resulting feature vector.</param>
        /// <param name="gridY">The number of cells in the vertical direction, 8 is a common value used in publications.
        /// The more cells, the finer the grid, the higher the dimensionality of the resulting feature vector.</param>
        /// <param name="threshold">The threshold applied in the prediction. If the distance to the nearest neighbor
        /// is larger than the threshold, this method returns -1.</param>
        /// <returns></returns>
        public static LBPHFaceRecognizer CreateLBPHFaceRecognizer(int radius = 1, int neighbors = 8,
                                                                  int gridX  = 8, int gridY     = 8, double threshold = Double.MaxValue)
        {
            IntPtr p = NativeMethods.face_createLBPHFaceRecognizer(radius, neighbors, gridX, gridY, threshold);

            return(LBPHFaceRecognizer.FromPtr(p));
        }
Пример #2
0
        /// <summary>
        /// Creates instance from cv::Ptr&lt;T&gt; .
        /// ptr is disposed when the wrapper disposes.
        /// </summary>
        /// <param name="ptr"></param>
        internal new static LBPHFaceRecognizer FromPtr(IntPtr ptr)
        {
            if (ptr == IntPtr.Zero)
            {
                throw new OpenCvSharpException($"Invalid cv::Ptr<{nameof(LBPHFaceRecognizer)}> pointer");
            }
            var ptrObj   = new Ptr(ptr);
            var detector = new LBPHFaceRecognizer
            {
                recognizerPtr = ptrObj,
                ptr           = ptrObj.Get()
            };

            return(detector);
        }
        /// <summary>
        /// The Circular Local Binary Patterns (used in training and prediction) expect the data given as
        /// grayscale images, use cvtColor to convert between the color spaces.
        /// This model supports updating.
        /// </summary>
        /// <param name="radius">The radius used for building the Circular Local Binary Pattern. The greater the radius, the</param>
        /// <param name="neighbors">The number of sample points to build a Circular Local Binary Pattern from.
        /// An appropriate value is to use `8` sample points.Keep in mind: the more sample points you include, the higher the computational cost.</param>
        /// <param name="gridX">The number of cells in the horizontal direction, 8 is a common value used in publications.
        /// The more cells, the finer the grid, the higher the dimensionality of the resulting feature vector.</param>
        /// <param name="gridY">The number of cells in the vertical direction, 8 is a common value used in publications.
        /// The more cells, the finer the grid, the higher the dimensionality of the resulting feature vector.</param>
        /// <param name="threshold">The threshold applied in the prediction. If the distance to the nearest neighbor
        /// is larger than the threshold, this method returns -1.</param>
        /// <returns></returns>
        // ReSharper disable once InconsistentNaming
        public static LBPHFaceRecognizer Create(int radius = 1, int neighbors = 8,
                                                int gridX  = 8, int gridY     = 8, double threshold = double.MaxValue)
        {
            IntPtr p = NativeMethods.face_LBPHFaceRecognizer_create(radius, neighbors, gridX, gridY, threshold);

            if (p == IntPtr.Zero)
            {
                throw new OpenCvSharpException($"Invalid cv::Ptr<{nameof(LBPHFaceRecognizer)}> pointer");
            }
            var ptrObj   = new Ptr(p);
            var detector = new LBPHFaceRecognizer
            {
                recognizerPtr = ptrObj,
                ptr           = ptrObj.Get()
            };

            return(detector);
        }