Esempio n. 1
0
        public DPacket GetDifferenceMask(Byte threshold)
        {
            DPacketReader rdr = new DPacketReader()
            {
                Resolution = _stateFrameDifferencingHighRes ? 16 : 8
            };

            DPacket packet = _c.SendCommandGetPacket(rdr, "MD", threshold);

            return(packet);
        }
Esempio n. 2
0
        /// <summary><para>Calls Frame Differencing against the last loaded frame (using the LoadFrame command). It returns data containing the middle mass, bounding box, pixel count, and confidence of any change since the previously loaded frame. It does this by calculating the average color intensity of an 8x8 grid of 64 regions ont he image and comparing those (plus or minus the threshhold value). The larger the threshold the less sensitive the camera will be towards differences in the image. Usually values between 5 and 20 yield good results.</para><para>In High-resolution mode a 16x16 grid is used with 256 regions.</para></summary>
        public DPacket GetDifference(Byte threshold)
        {
            SetLineMode(LineMode.Differencing, 0);

            DPacketReader rdr = new DPacketReader()
            {
                Resolution = _stateFrameDifferencingHighRes ? 16 : 8
            };

            DPacket dpak = _c.SendCommandGetPacket(rdr, "FD", threshold);

            return(dpak);
        }
Esempio n. 3
0
        protected void PaintDifference(Graphics g)
        {
            DPacket p = _dPacket;

            if (p == null)
            {
                return;
            }

            //////////////////////////////////////
            // Draw gridlines
            Rectangle rect       = FrameRectangle;
            int       cellWidth  = (int)((float)rect.Width / (float)p.XAxisSegments);
            int       cellHeight = (int)((float)rect.Height / (float)p.YAxisSegments);

            for (int y = 0; y < p.XAxisSegments; y++)
            {
                for (int x = 0; x < p.YAxisSegments; x++)
                {
                    Rectangle thisCell = new Rectangle(rect.X + x * cellWidth, rect.Y + y * cellHeight, cellWidth, cellHeight);

                    g.DrawRectangle(Pens.Black, thisCell);

                    if (p.PixelCount > 0)
                    {
                        if (p.Rectangle.Contains(x, y))
                        {
                            g.FillRectangle(Brushes.Blue, thisCell);
                        }

                        if (p.Centroid.X - 1 == x && p.Centroid.Y - 1 == y)
                        {
                            g.FillRectangle(Brushes.White, thisCell);
                        }
                    }    //if
                }        //for
            }            //for

            String text = String.Format("Confidence: {0}\nPixel Count: {1}", p.Confidence, p.PixelCount);

            g.DrawString(text, SystemFonts.IconTitleFont, SystemBrushes.ControlText, 5, FrameRectangle.Height + 5);
        }