Accord.Vision.Detection.HaarRectangle.ScaleWeight C# (CSharp) Method

ScaleWeight() public method

Scales the weight of this rectangle.
public ScaleWeight ( float scale ) : void
scale float
return void
        public void ScaleWeight(float scale)
        {
            ScaledWeight = Weight * scale;
        }

Usage Example

Example #1
0
        /// <summary>
        ///   Sets the scale and weight of a Haar-like rectangular feature container.
        /// </summary>
        ///
        public void SetScaleAndWeight(float scale, float weight)
        {
            // manual loop unfolding

            if (Rectangles.Length == 2)
            {
                HaarRectangle a = Rectangles[0];
                HaarRectangle b = Rectangles[1];

                b.ScaleRectangle(scale);
                b.ScaleWeight(weight);

                a.ScaleRectangle(scale);
                a.ScaledWeight = -(b.Area * b.ScaledWeight) / a.Area;
            }
            else // rectangles.Length == 3
            {
                HaarRectangle a = Rectangles[0];
                HaarRectangle b = Rectangles[1];
                HaarRectangle c = Rectangles[2];

                c.ScaleRectangle(scale);
                c.ScaleWeight(weight);

                b.ScaleRectangle(scale);
                b.ScaleWeight(weight);

                a.ScaleRectangle(scale);
                a.ScaledWeight = -(b.Area * b.ScaledWeight
                                   + c.Area * c.ScaledWeight) / (a.Area);
            }
        }