Camfight.Form1.ProcessFrame C# (CSharp) Method

ProcessFrame() private method

private ProcessFrame ( ) : void
return void
        private void ProcessFrame()
        {
            while (true)
            {
                Image<Bgr, Byte> frame = _capture.QueryFrame();
                FPU.ProcessFrame(frame);

                fpu_mutex.WaitOne();
                fpu_container.SetVar(FPU);
                fpu_mutex.ReleaseMutex();

                int face_sector = GetSector(new Point(FPU.face.X + FPU.face.Width / 2, FPU.face.Y + FPU.face.Height / 2),frame.Size);
                int left_sector = GetSector(FPU.center[1],frame.Size);
                int right_sector = GetSector(FPU.center[0],frame.Size);

                int sector = (right_sector << 8) + (left_sector << 4) + face_sector;

                if (FPU.have_left_punch == true)
                {
                    sector = sector | 0xF00;
                }
                else if (FPU.have_right_punch == true)
                {
                    sector = sector | 0xF0;
                }
                bool big = false;
                if (FPU.have_right)
                {
                    int this_big = sec_to_big(right_sector);
                    if (this_big != last_big_move)
                    {
                        if (big_move_q.Count >= 30)
                        {
                            big_move_q.Dequeue();
                        }
                        big_move_q.Enqueue(this_big);
                        big = check_big_move();
                        last_big_move = this_big;
                    }
                }
                else if (FPU.have_left)
                {
                    int this_big = sec_to_big(left_sector);
                    if (this_big != last_big_move)
                    {
                        if (big_move_q.Count >= 30)
                        {
                            big_move_q.Dequeue();
                        }
                        big_move_q.Enqueue(this_big);
                        big = check_big_move();
                        last_big_move = this_big;
                    }
                }

                frame.Draw(FPU.face, new Bgr(Color.Blue), 2);
                if (FPU.have_left)
                {
                    frame.Draw(FPU.left, new Bgr(Color.Green), 2);
                }
                if (FPU.have_right)
                {
                    frame.Draw(FPU.right, new Bgr(Color.Yellow), 2);
                }
                frame = frame.Flip(FLIP.HORIZONTAL);

                if (show_back)
                {
                    pictureBox1.Image = FPU.backproject.Bitmap;
                }
                else
                {
                    pictureBox1.Image = frame.Bitmap;
                }
                this.Invoke(new InvokeFunction(pictureBox1.Refresh));
                this.Invoke(new InvokeFunction(pictureBox1.Show));
                //pictureBox1.Refresh();
                //pictureBox1.Show();

                packet pac = new packet("play", enemyname, "", 0, 0, sector, big);

                if (gamestate == GameState.GAME)
                {
                    SendPacket(pac);
                }
                else if (gamestate == GameState.SINGLE)
                {
                    this.Invoke(new InvokeFunction2(this.mymove), pac);
                }

            }
        }