示例#1
0
        private void Count_timer_Tick(object sender, EventArgs e)
        {
            Countbox.Visible = true;
            Countbox.Image   = timePhotos[c_flag];
            c_flag++;

            if (c_flag > 3)
            {
                face_image = camera.QueryFrame();
                faces      =
                    gray.DetectHaarCascade(haar, 1.2, 10,
                                           HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
                                           new Size(25, 25))[0];

                Count_timer.Stop();

                Camera_timer.Start();
            }
        }
示例#2
0
        //啟動動畫timer
        private void Animation_timer_Tick(object sender, EventArgs e)
        {
            //定義距離每格數的(X,Y)
            int new_x = pictureBoxCenter.Location.X - vx;
            int new_y = pictureBoxCenter.Location.Y - vy;

            pictureBoxCenter.Location = new Point(new_x, new_y);

            //定義每次移動一格,box大小的變化量
            int new_w = pictureBoxCenter.Width - v_size;
            int new_h = pictureBoxCenter.Height - v_size;

            pictureBoxCenter.Size = new Size(new_w, new_h);

            ani_count++;//每移動一格,計數器+1(移動一格timer執行一次)

            //設定影像紅框閃爍,以2的餘數做判斷
            if ((ani_count % 2) == 1)
            {
                Redbox.Visible = true;
            }
            else
            {
                Redbox.Visible = false;
            }

            //若做完動畫後,pictureBoxCenter回復原來大小與位置,等待下一次執行
            if (ani_count > (fps - 1))
            {
                ani_count = 0;

                pictureBoxCenter.Size     = new Size(b_size * scale, b_size * scale);                //計算pictureBoxCenter大小
                pictureBoxCenter.Location = new Point(rx - (b_size * scale), ry - (b_size * scale)); //計算pictureBoxCenter位置
                pictureBoxCenter.Visible  = false;

                Animation_timer.Stop(); //動畫結束

                Camera_timer.Start();   //重新啟動偵測人臉
            }
        }