/// <summary> /// Performs object detection with increasing detection window. /// </summary> /// <param name="image">The image to search in</param> /// <param name="hitThreshold"> /// Threshold for the distance between features and SVM classifying plane. /// Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient). /// But if the free coefficient is omitted (which is allowed), you can specify it manually here. ///</param> /// <param name="winStride">Window stride. Must be a multiple of block stride.</param> /// <param name="padding"></param> /// <param name="scale">Coefficient of the detection window increase.</param> /// <param name="finalThreshold">After detection some objects could be covered by many rectangles. This coefficient regulates similarity threshold. 0 means don't perform grouping. Should be an integer if not using meanshift grouping. Use 2.0 for default</param> /// <param name="useMeanshiftGrouping">If true, it will use meanshift grouping.</param> /// <returns>The regions where positives are found</returns> public MCvObjectDetection[] DetectMultiScale( IInputArray image, double hitThreshold = 0, Size winStride = new Size(), Size padding = new Size(), double scale = 1.05, double finalThreshold = 2.0, bool useMeanshiftGrouping = false) { using (Util.VectorOfRect vr = new VectorOfRect()) using (Util.VectorOfDouble vd = new VectorOfDouble()) using (InputArray iaImage = image.GetInputArray()) { CvInvoke.cveHOGDescriptorDetectMultiScale(_ptr, iaImage, vr, vd, hitThreshold, ref winStride, ref padding, scale, finalThreshold, useMeanshiftGrouping); Rectangle[] location = vr.ToArray(); double[] weight = vd.ToArray(); MCvObjectDetection[] result = new MCvObjectDetection[location.Length]; for (int i = 0; i < result.Length; i++) { MCvObjectDetection od = new MCvObjectDetection(); od.Rect = location[i]; od.Score = (float)weight[i]; result[i] = od; } return result; } }
/// <summary> /// Performs object detection with increasing detection window. /// </summary> /// <param name="image">The CudaImage to search in</param> /// <returns>The regions where positives are found</returns> public MCvObjectDetection[] DetectMultiScale(IInputArray image) { using (Util.VectorOfRect vr = new VectorOfRect()) using (Util.VectorOfDouble vd = new VectorOfDouble()) { DetectMultiScale(image, vr, vd); Rectangle[] location = vr.ToArray(); double[] weight = vd.ToArray(); MCvObjectDetection[] result = new MCvObjectDetection[location.Length]; for (int i = 0; i < result.Length; i++) { MCvObjectDetection od = new MCvObjectDetection(); od.Rect = location[i]; od.Score = (float)weight[i]; result[i] = od; } return result; } }