示例#1
0
 internal static extern Seq cvHaarDetectObjects(
     Arr image,
     HaarClassifierCascade cascade,
     MemStorage storage,
     double scale_factor,
     int min_neighbors,
     HaarDetectObjectFlags flags,
     Size min_size,
     Size max_size);
        /// <summary>
        /// Detects objects in the image.
        /// </summary>
        /// <param name="image">Image to detect objects in.</param>
        /// <param name="storage">Memory storage to store the resultant sequence of the object candidate rectangles.</param>
        /// <param name="scaleFactor">
        /// The factor by which the search window is scaled between the subsequent scans, 1.1 means increasing window by 10%.
        /// </param>
        /// <param name="minNeighbors">
        /// Minimum number (minus 1) of neighbor rectangles that make up an object. All the groups of a smaller number of
        /// rectangles than <paramref name="minNeighbors"/>-1 are rejected. If it is 0, the method does not do any grouping
        /// at all and returns all the detected candidate rectangles, which may be useful if the user wants to apply a
        /// customized grouping procedure.
        /// </param>
        /// <param name="flags">Mode of operation.</param>
        /// <param name="minSize">
        /// Minimum window size. By default, it is set to the size of samples the classifier has been trained on
        /// (20x20 for face detection).
        /// </param>
        /// <param name="maxSize">Maximum window size. By default, it is set to the total image size.</param>
        /// <returns>The sequence of grouped (or ungrouped) object rectangles.</returns>
        public Seq DetectObjects(
            Arr image,
            MemStorage storage,
            double scaleFactor          = 1.1,
            int minNeighbors            = 3,
            HaarDetectObjectFlags flags = HaarDetectObjectFlags.None,
            Size minSize = default(Size),
            Size maxSize = default(Size))
        {
            var objects = NativeMethods.cvHaarDetectObjects(image, this, storage, scaleFactor, minNeighbors, flags, minSize, maxSize);

            if (objects.IsInvalid)
            {
                return(null);
            }
            objects.SetOwnerStorage(storage);
            return(objects);
        }