Example #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            Image <Bgr, Byte> frame = _capture.QueryFrame();
            bool bface = hasFaces(frame);

            if (bface)
            {
                this.Opacity = 0;
                dtWhenFound  = DateTime.MinValue;
                //findFaces(frame);
            }
            else
            {
                if (dtWhenFound == DateTime.MinValue)
                {
                    dtWhenFound = DateTime.Now;
                }
                this.Opacity     = 1;
                this.WindowState = FormWindowState.Maximized;
                TimeSpan tsDiff = new TimeSpan(DateTime.Now.Ticks - dtWhenFound.Ticks);
                if (tsDiff.TotalSeconds > 3)
                {
                    //closeFire();
                }
            }
            this.Text = "Hasface:" + bface;
            if (trainedimg != null)
            {
                EyeOpen.Imaging.ComparableImage ci = new EyeOpen.Imaging.ComparableImage(trainedimg);
                double dblSim = ci.CalculateSimilarity(new EyeOpen.Imaging.ComparableImage(frame.Bitmap));
                this.Text += ", Similarity:" + dblSim;
            }

            //pictureBox1.Image = frame.Bitmap;
        }
Example #2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            Image<Bgr, Byte> frame = _capture.QueryFrame();
            bool bface = hasFaces(frame);
            if (bface)
            {
                this.Opacity = 0;
                dtWhenFound = DateTime.MinValue;
                //findFaces(frame);
            }
            else
            {
                if (dtWhenFound == DateTime.MinValue)
                    dtWhenFound = DateTime.Now;
                this.Opacity = 1;
                this.WindowState = FormWindowState.Maximized;
                TimeSpan tsDiff = new TimeSpan(DateTime.Now.Ticks - dtWhenFound.Ticks);
                if (tsDiff.TotalSeconds > 3)
                {
                    //closeFire();
                }
            }
            this.Text = "Hasface:" + bface;
            if (trainedimg != null)
            {
                EyeOpen.Imaging.ComparableImage ci = new EyeOpen.Imaging.ComparableImage(trainedimg);
                double dblSim = ci.CalculateSimilarity(new EyeOpen.Imaging.ComparableImage(frame.Bitmap));
                this.Text += ", Similarity:" + dblSim;
            }

            //pictureBox1.Image = frame.Bitmap;
        }
Example #3
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            ScreenCapture sc = new ScreenCapture();

            if (xstart > 0 && ystart > 0 && iwidth > 0 && iheight > 0 && !setSizeToolStripMenuItem.Checked)
            {
                if (icnt > 150)
                {
                    //pictureBox1.Image = null;
                }
                Image img = sc.CaptureScreen(xstart, ystart, iwidth, iheight);

                EyeOpen.Imaging.ComparableImage ci = new EyeOpen.Imaging.ComparableImage(bmp);
                double dblSim = ci.CalculateSimilarity(new EyeOpen.Imaging.ComparableImage(img as Bitmap));
                if (dblSim > .1)
                {
                    pictureBox1.Image = img;
                }
                bool bWhat = dblSim > .82;

                if (bWhat)// && icnt>5)
                {
                    this.Text = Math.Round(dblSim, 4).ToString() + ":" + System.DateTime.Now.ToString("HH:mm:ss") + "_" + icnt;
                    Bitmap b = CreateBitmap(Color.Red, new Point(pictureBox1.Width, pictureBox1.Height));
                    pictureBox1.Image = b;

                    timer1.Enabled = false;

                    user32.setCursorPos(xstart + 20, ystart + 20);
                    user32.sendInput(new[] {
                        new user32.MOUSEINPUT()
                        {
                            dwFlags = user32.MOUSEEVENTF.LEFTDOWN, dwExtraInfo = (UIntPtr)user32.Messages.WM_LBUTTONDOWN, dx = xstart + 20, dy = ystart + 20
                        },
                        new user32.MOUSEINPUT()
                        {
                            dwFlags = user32.MOUSEEVENTF.LEFTUP, dwExtraInfo = (UIntPtr)user32.Messages.WM_LBUTTONUP, dx = xstart + 20, dy = ystart + 20
                        }
                    });

                    System.Windows.Forms.Timer t = new System.Windows.Forms.Timer();
                    t.Interval = 2000;
                    t.Enabled  = true;
                    t.Tick    += (a, x) => {
                        user32.setCursorPos(xstart - 20, ystart - 20);
                        timer1.Enabled = true;
                        t.Enabled      = false;
                    };

                    //mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, xstart, ystart, icnt, icnt);
                    icnt++;
                }
                if (saveToolStripMenuItem.Checked)
                {
                    img.Save(Application.CommonAppDataPath + "\\" + System.DateTime.Now.Ticks.ToString() + ".png", System.Drawing.Imaging.ImageFormat.Png);
                }
                //icnt++;
            }
        }
Example #4
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            ScreenCapture sc = new ScreenCapture();
            if (xstart > 0 && ystart > 0 && iwidth > 0 && iheight > 0 && !setSizeToolStripMenuItem.Checked)
            {
                if (icnt > 150)
                {
                    //pictureBox1.Image = null;
                }
                Image img = sc.CaptureScreen(xstart, ystart, iwidth, iheight);
                
                EyeOpen.Imaging.ComparableImage ci = new EyeOpen.Imaging.ComparableImage(bmp);
                double dblSim = ci.CalculateSimilarity(new EyeOpen.Imaging.ComparableImage(img as Bitmap));
                if (dblSim > .1)
                {
                    pictureBox1.Image = img;
                }
                bool bWhat = dblSim > .82;
                    
                if (bWhat)// && icnt>5)
                {
                    this.Text = Math.Round(dblSim, 4).ToString() + ":" + System.DateTime.Now.ToString("HH:mm:ss")+"_"+icnt;
                    Bitmap b = CreateBitmap(Color.Red, new Point(pictureBox1.Width, pictureBox1.Height));
                    pictureBox1.Image = b;
                    
                    timer1.Enabled = false;
                    
                    user32.setCursorPos(xstart + 20, ystart + 20);
                    user32.sendInput(new[]{
                        new user32.MOUSEINPUT() { dwFlags = user32.MOUSEEVENTF.LEFTDOWN,dwExtraInfo=(UIntPtr)user32.Messages.WM_LBUTTONDOWN, dx = xstart + 20, dy = ystart + 20 },
                        new user32.MOUSEINPUT() { dwFlags = user32.MOUSEEVENTF.LEFTUP,dwExtraInfo=(UIntPtr)user32.Messages.WM_LBUTTONUP, dx = xstart + 20, dy = ystart + 20 }
                    });

                    System.Windows.Forms.Timer t = new System.Windows.Forms.Timer();
                    t.Interval = 2000;
                    t.Enabled = true;
                    t.Tick += (a,x) => {
                        user32.setCursorPos(xstart - 20, ystart - 20);
                        timer1.Enabled = true;
                        t.Enabled = false;
                    };

                    //mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, xstart, ystart, icnt, icnt);
                    icnt++;
                }
                if (saveToolStripMenuItem.Checked)
                {
                    img.Save(Application.CommonAppDataPath + "\\" + System.DateTime.Now.Ticks.ToString() + ".png", System.Drawing.Imaging.ImageFormat.Png);
                }
                //icnt++;
            }
        }
Example #5
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            
            Image img = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            Graphics g = Graphics.FromImage(img);

            Screen s = Screen.FromHandle(board.Handle);            
            g.CopyFromScreen(0,0,0,0,new Size(s.WorkingArea.Width,s.WorkingArea.Height));
            //pictureBox1.Image = img;
            
            Image<Bgr, Byte> frame = _capture.QueryFrame();
            //pictureBox1.Image = frame.Bitmap;

            EyeOpen.Imaging.ComparableImage ci = new EyeOpen.Imaging.ComparableImage(img as Bitmap);
            double dblSim = ci.CalculateSimilarity(new EyeOpen.Imaging.ComparableImage(frame.Bitmap));
            this.Text = "Similarity:" + dblSim + "_" + s.DeviceName;
            if(dblSim>.6)
                pictureBox1.Image = frame.Bitmap;
        }
Example #6
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            Image    img = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            Graphics g   = Graphics.FromImage(img);

            Screen s = Screen.FromHandle(board.Handle);

            g.CopyFromScreen(0, 0, 0, 0, new Size(s.WorkingArea.Width, s.WorkingArea.Height));
            //pictureBox1.Image = img;

            Image <Bgr, Byte> frame = _capture.QueryFrame();

            //pictureBox1.Image = frame.Bitmap;

            EyeOpen.Imaging.ComparableImage ci = new EyeOpen.Imaging.ComparableImage(img as Bitmap);
            double dblSim = ci.CalculateSimilarity(new EyeOpen.Imaging.ComparableImage(frame.Bitmap));

            this.Text = "Similarity:" + dblSim + "_" + s.DeviceName;
            if (dblSim > .6)
            {
                pictureBox1.Image = frame.Bitmap;
            }
        }