public Point[] Detect(Image <Bgr, Byte> img, int classifierId)
        {
            DetectHaarSample sample = new DetectHaarSample(img);
            int  width  = sample.Size.Width;
            int  height = sample.Size.Height;
            Size window = _cascade.Size;
            int  yEnd   = height - window.Height;
            int  xEnd   = width - window.Width;

            List <Point> result = new List <Point>((int)Math.Sqrt((xEnd + 1) * (yEnd + 1)));

            for (int y = 0; y <= yEnd; y += _yStep)
            {
                for (int x = 0; x <= xEnd; x += _xStep)
                {
                    Point      offset    = new Point(x, y);
                    HaarSample subSample = new HaarSample(sample, offset, window);
                    if (_cascade.PredictUseOneClassifier(subSample, classifierId))
                    {
                        result.Add(offset);
                    }
                }
            }

            return(result.ToArray());
        }
Exemple #2
0
 public HaarSample(DetectHaarSample fullSample, Point offset, Size windowSize)
 {
     _grayIntergralImage       = fullSample._grayIntergralImage;
     _saturationIntergralImage = fullSample._saturationIntergralImage;
     _graySquareIntergralImage = fullSample._graySquareIntergralImage;
     _xOffset = offset.X;
     _yOffset = offset.Y;
     CalcMeanAndStd(windowSize);
 }