Subtract() public static method

Subtraction operator - subtracts values of two points.
public static Subtract ( IntPoint point1, IntPoint point2 ) : IntPoint
point1 IntPoint Point to subtract from.
point2 IntPoint Point to subtract.
return IntPoint
Exemplo n.º 1
0
        private void initTracking(Bgr <byte>[,] frame)
        {
            initializeKalman(roi.Center());

            //get hue channel from search area
            var hsvImg = frame.ToHsv();

            //user constraints...

            Gray <byte>[,] mask = hsvImg.InRange(new Hsv <byte>(0, 0, (byte)minV), new Hsv <byte>(0, 0, (byte)maxV), Byte.MaxValue, 2);

            originalObjHist.Calculate(hsvImg.SplitChannels <Hsv <byte>, byte>(roi, 0, 1), false, mask, roi.Location);
            originalObjHist.Scale((float)1 / roi.Area());
            //originalObjHist.Normalize(Byte.MaxValue);

            var backgroundArea = roi.Inflate(1.5, 1.5, frame.Size());
            var backgroundMask = mask.Clone(backgroundArea);

            backgroundMask.SetValue <Gray <byte> >(0, new Rectangle(Point.Subtract(roi.Location, backgroundArea.Location), roi.Size));

            backgroundHist.Calculate(hsvImg.SplitChannels <Hsv <byte>, byte>(backgroundArea, 0, 1), false, mask, backgroundArea.Location);
            backgroundHist.Scale((float)1 / (backgroundArea.Area() - roi.Area()));
            //backgroundHist.Normalize(Byte.MaxValue);

            //how good originalObjHist and objHist match (suppresses possible selected background)
            ratioHist = originalObjHist.CreateRatioHistogram(backgroundHist, Byte.MaxValue, 3);

            searchArea = roi;
            roi        = Rectangle.Empty;
        }
Exemplo n.º 2
0
        private void initTracking(Image <Bgr, byte> frame)
        {
            initializeKalman(roi.Center());

            //get hue channel from search area
            var hsvImg = frame.Convert <Hsv, byte>(); //<<parallel operation>>
            //user constraints...

            Image <Gray, byte> mask = hsvImg.InRange(new Hsv(0, 0, minV), new Hsv(0, 0, maxV), Byte.MaxValue, 2);

            originalObjHist.Calculate(hsvImg.GetSubRect(roi).SplitChannels(0, 1), false, mask.GetSubRect(roi));
            originalObjHist.Scale((float)1 / roi.Area());
            //originalObjHist.Normalize(Byte.MaxValue);

            var backgroundArea = roi.Inflate(1.5, 1.5, frame.Size);
            var backgroundMask = mask.GetSubRect(backgroundArea).Clone();

            backgroundMask.GetSubRect(new Rectangle(Point.Subtract(roi.Location, backgroundArea.Location), roi.Size)).SetValue(0);

            backgroundHist.Calculate(hsvImg.GetSubRect(backgroundArea).SplitChannels(0, 1), false, mask.GetSubRect(backgroundArea));
            backgroundHist.Scale((float)1 / (backgroundArea.Area() - roi.Area()));
            //backgroundHist.Normalize(Byte.MaxValue);

            //how good originalObjHist and objHist match (suppresses possible selected background)
            ratioHist = originalObjHist.CreateRatioHistogram(backgroundHist, Byte.MaxValue, 3);

            searchArea = roi;
            roi        = Rectangle.Empty;
        }