예제 #1
0
 /// <summary>
 /// Detects objects of different sizes in the input image.
 /// </summary>
 /// <param name="image">Matrix of type CV_8U containing an image where objects should be detected.</param>
 /// <param name="objects">Buffer to store detected objects (rectangles).</param>
 /// <param name="stream">Use a Stream to call the function asynchronously (non-blocking) or null to call the function synchronously (blocking).</param>
 public void DetectMultiScale(IInputArray image, IOutputArray objects, Stream stream = null)
 {
     using (InputArray iaImage = image.GetInputArray())
     using (OutputArray oaObjects = objects.GetOutputArray())
         CudaInvoke.cudaCascadeClassifierDetectMultiScale(_ptr, iaImage, oaObjects,
            stream == null ? IntPtr.Zero : stream.Ptr);
 }
예제 #2
0
 /// <summary>
 /// Finds rectangular regions in the given image that are likely to contain objects the cascade has been trained for and returns those regions as a sequence of rectangles.
 /// </summary>
 /// <param name="image">The image where search will take place</param>
 /// <param name="scaleFactor">The factor by which the search window is scaled between the subsequent scans, for example, 1.1 means increasing window by 10%. Use 1.2 for default.</param>
 /// <param name="minNeighbors">Minimum number (minus 1) of neighbor rectangles that makes up an object. All the groups of a smaller number of rectangles than min_neighbors-1 are rejected. If min_neighbors is 0, the function does not 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. Use 4 for default.</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). Use Size.Empty for default</param>
 /// <returns>An array of regions for the detected objects</returns>
 public Rectangle[] DetectMultiScale(GpuMat image, double scaleFactor = 1.2, int minNeighbors = 4, Size minSize = new Size())
 {
     try
     {
         Seq <Rectangle> regions = new Seq <Rectangle>(_stor);
         int             count   = CudaInvoke.cudaCascadeClassifierDetectMultiScale(_ptr, image, _buffer, scaleFactor, minNeighbors, minSize, regions);
         if (count == 0)
         {
             return(new Rectangle[0]);
         }
         Rectangle[] result = regions.ToArray();
         return(result);
     }
     finally
     {
         _stor.Clear();
     }
 }