public FormGroupMatch()
        {
            InitializeComponent();
            debugImage = new Image<Bgr, byte>(pictureBox.Size.ToSize());

            var detections = getDetections();
            drawDetections(detections, Bgr8.Red, 3);

            groupMatching = new RectangleGroupMatching(minimumNeighbors: 1, threshold: 0.3);
            var clusters = groupMatching.Group(detections);

            drawDetections(clusters.Select(x => x.Representative), Bgr8.Green, 1);
            pictureBox.Image = debugImage.ToBitmap();
        }
Exemplo n.º 2
0
        public FormGroupMatch()
        {
            InitializeComponent();
            debugImage = new Image <Bgr, byte>(pictureBox.Size.ToSize());

            var detections = getDetections();

            drawDetections(detections, Bgr8.Red, 3);

            groupMatching = new RectangleGroupMatching(minimumNeighbors: 1, threshold: 0.3);
            var clusters = groupMatching.Group(detections);

            drawDetections(clusters.Select(x => x.Representative), Bgr8.Green, 1);
            pictureBox.Image = debugImage.ToBitmap();
        }
        /// <summary>
        ///   Constructs a new Haar object detector.
        /// </summary>
        /// 
        /// <param name="cascade">
        ///   The <see cref="HaarCascade"/> to use in the detector's classifier.
        ///   For the default face cascade, please take a look on
        ///   <see cref="Cascades.FaceHaarCascade"/>. </param>
        /// <param name="minSize">
        ///   Minimum window size to consider when searching for
        ///   objects. Default value is <c>15</c>.</param>
        /// <param name="searchMode">The <see cref="ObjectDetectorSearchMode"/> to use
        ///   during search. Please see documentation of <see cref="ObjectDetectorSearchMode"/>
        ///   for details. Default is <see cref="ObjectDetectorSearchMode.NoOverlap"/>.</param>
        /// <param name="scaleFactor">The scaling factor to rescale the window
        ///   during search. Default value is <c>1.2f</c>.</param>
        /// <param name="scalingMode">The <see cref="ObjectDetectorScalingMode"/> to use
        ///   when re-scaling the search window during search. Default is
        ///   <see cref="ObjectDetectorScalingMode.SmallerToGreater"/>.</param>
        /// 
        public HaarObjectDetector(HaarCascade cascade, int minSize,
            ObjectDetectorSearchMode searchMode, float scaleFactor,
            ObjectDetectorScalingMode scalingMode)
        {
            this.classifier = new HaarClassifier(cascade);
            this.minSize = new Size(minSize, minSize);
            this.searchMode = searchMode;
            this.ScalingMode = scalingMode;
            this.factor = scaleFactor;
            this.detectedObjects = new List<Rectangle>();

            this.baseWidth = cascade.Width;
            this.baseHeight = cascade.Height;

            this.match = new RectangleGroupMatching(0, 0.2);
        }
Exemplo n.º 4
0
 private static bool areMatchesNear(Match m1, Match m2, double threshold)
 {
     return(RectangleGroupMatching.AreRectanglesNear(m1.BoundingRect, m2.BoundingRect, threshold));
 }