/// <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. /// The function scans the image several times at different scales. Each time it considers overlapping regions in the image. /// It may also apply some heuristics to reduce number of analyzed regions, such as Canny prunning. /// After it has proceeded and collected the candidate rectangles (regions that passed the classifier cascade), it groups them and returns a sequence of average rectangles for each large enough group. /// </summary> /// <param name="image">The image where the objects are to be detected from</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%</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 3 for default.</param> /// <param name="minSize">Minimum window size. Use Size.Empty for default, where 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. Use Size.Empty for default, where the parameter will be ignored.</param> /// <returns>The objects detected, one array per channel</returns> public Rectangle[] DetectMultiScale(IInputArray image, double scaleFactor = 1.1, int minNeighbors = 3, Size minSize = new Size(), Size maxSize = new Size()) { using (Util.VectorOfRect rectangles = new Util.VectorOfRect()) using (InputArray iaImage = image.GetInputArray()) { CvCascadeClassifierDetectMultiScale(_ptr, iaImage, rectangles, scaleFactor, minNeighbors, 0, ref minSize, ref maxSize); return(rectangles.ToArray()); } }
/// <summary> /// Create the standard vector of VectorOfRect /// </summary> public VectorOfVectorOfRect(Rectangle[][] values) : this() { using (VectorOfRect v = new VectorOfRect()) { for (int i = 0; i < values.Length; i++) { v.Push(values[i]); Push(v); v.Clear(); } } }
/// <summary> /// Convert the standard vector to arrays of int /// </summary> /// <returns>Arrays of int</returns> public Rectangle[][] ToArrayOfArray() { int size = Size; Rectangle[][] res = new Rectangle[size][]; for (int i = 0; i < size; i++) { using (VectorOfRect v = this[i]) { res[i] = v.ToArray(); } } return(res); }
/// <summary> /// Push a value into the standard vector /// </summary> /// <param name="value">The value to be pushed to the vector</param> public void Push(VectorOfRect value) { VectorOfVectorOfRectPush(_ptr, value.Ptr); }
public DebuggerProxy(VectorOfRect v) { _v = v; }
/// <summary> /// Push multiple values from the other vector into this vector /// </summary> /// <param name="other">The other vector, from which the values will be pushed to the current vector</param> public void Push(VectorOfRect other) { VectorOfRectPushVector(_ptr, other); }