Exemple #1
0
 public void Initialize(Image <Gray, byte> initialFrame, IBoundingBox initialBb)
 {
     initialFrame.Integral(out _sum, out _squareSum);
     initialBb.ScanningWindow = initialBb.CreateScanningWindow();
     Service.SetIntegralImage(_sum);
     Service.SetSquaredIntegralImage(_squareSum);
     _initialVariance = Service.GetPatchVariance(initialBb);
     _threshold       = _thresholdCoefficient * _initialVariance;
     _acceptedWindows = new List <int>(_scanningWindowGenerator.ScanningWindows.Length);
 }
Exemple #2
0
        public IBoundingBox[] Generate(Size frameSize, IBoundingBox initialBb)
        {
            _frameSize          = frameSize;
            _initialBoundingBox = initialBb;
            _windowsGenerated   = true;

            List <IBoundingBox> _scanningWindowsList = new List <IBoundingBox>();

            // define minimum bounding box size
            float minSideSize = Math.Min(initialBb.Size.Width, initialBb.Size.Height);
            float ratio       = minSideSize / _minSize;
            Size  minBbSize   = new Size
                                (
                (int)Math.Ceiling(initialBb.Size.Width / ratio),
                (int)Math.Ceiling(initialBb.Size.Height / ratio)
                                );

            // create bounding boxes
            Size bbSize = minBbSize;

            while (bbSize.Width <= frameSize.Width && bbSize.Height <= frameSize.Height)
            {
                // define x and y step
                float xStep = bbSize.Width * _xRelStep;
                float yStep = bbSize.Height * _yRelStep;

                for (float bbCenterY = bbSize.Height / 2.0f - 0.5f; bbCenterY + bbSize.Height / 2.0f <= frameSize.Height - 0.5f; bbCenterY += yStep)
                {
                    for (float bbCenterX = bbSize.Width / 2.0f - 0.5f; bbCenterX + bbSize.Width / 2.0f <= frameSize.Width - 0.5f; bbCenterX += xStep)
                    {
                        IBoundingBox bb = initialBb.CreateInstance(
                            new PointF(bbCenterX, bbCenterY),
                            bbSize
                            );
                        bb.ScanningWindow = bb.CreateScanningWindow();

                        _scanningWindowsList.Add(bb);
                    }
                }

                bbSize = new Size((int)(bbSize.Width * _scaleStep), (int)(bbSize.Height * _scaleStep));
            }

            _scanningWindows = _scanningWindowsList.ToArray();
            return(_scanningWindows);
        }