GetSum2() public method

Gets the sum of the squared pixels in a rectangle of the Integral image.
public GetSum2 ( int x, int y, int width, int height ) : long
x int The horizontal position of the rectangle x.
y int The vertical position of the rectangle y.
width int The rectangle's width w.
height int The rectangle's height h.
return long
コード例 #1
0
ファイル: HaarClassifier.cs プロジェクト: BiYiTuan/framework
        /// <summary>
        ///   Detects the presence of an object in a given window.
        /// </summary>
        /// 
        public bool Compute(IntegralImage2 image, Rectangle rectangle)
        {
            int x = rectangle.X;
            int y = rectangle.Y;
            int w = rectangle.Width;
            int h = rectangle.Height;

            double mean = image.GetSum(x, y, w, h) * invArea;
            double var = image.GetSum2(x, y, w, h) * invArea - (mean * mean);
            double sdev = (var >= 0) ? Math.Sqrt(var) : 1;


            // For each classification stage in the cascade
            foreach (HaarCascadeStage stage in cascade.Stages)
            {
                // Check if the stage has rejected the image
                if (stage.Classify(image, x, y, sdev) == false)
                {
                    return false; // The image has been rejected.
                }
            }

            // If the object has gone all stages and has not
            //  been rejected, the object has been detected.

            return true; // The image has been detected.
        }