コード例 #1
0
        private void Mission2_Click(object sender, EventArgs e)
        {
            mDrone.droneMudarCamara(Drone.DroneCamera.FRONTAL);

            mDrone.droneDescolar();

            while (true)
            {
                while (true)
                {
                    mDrone.imageChange += new Drone.droneImageHandler(atualizarImagemOnly);

                    if (ImageFrame.Bitmap != null)
                    {
                        break;
                    }
                }

                imgsize.X = ImageFrame.Width;
                imgsize.Y = ImageFrame.Height;

                img1 = ProImg.HsvROI(ImageFrame, m4_hsv_hlow, m4_hsv_hhi, m4_hsv_slow, m4_hsv_shi, m4_hsv_vlow, m4_hsv_vhi, m4_hsv_h, m4_hsv_s, m4_hsv_v, m4_hsv_invert);

                img1 = img1.SmoothGaussian(9);

                // centra circulo com o drone
                Centra_Circulo_CAM1(ImageFrame, Convert.ToInt32(H_Lval.Text), Convert.ToInt32(H_Hval.Text),
                                    Convert.ToInt32(S_Lval.Text), Convert.ToInt32(S_Hval.Text), Convert.ToInt32(V_Lval.Text),
                                    Convert.ToInt32(V_Hval.Text), H.Checked, S.Checked, V.Checked, Invert.Checked,
                                    Convert.ToDouble(Area.Text));

                //faz circulo a volta do objeto
                ProImg.Deteccao_Circulo(img1, ImageFrame, (m4_area_obj * mDrone.droneObterAltitude()));

                mDrone.droneMoverPRO(droneTraj.Vel_x_drone, droneTraj.Vel_y_drone, 0.01f, droneTraj.Vel_rot_z_drone);


                //renvia imagem para as picturebox's
                pictureBox1.Image = ImageFrame.Bitmap;
                pictureBox2.Image = img1.Bitmap;

                //envia informaçoes do drone
                EstadoDrone();

                //mediante a area o drone vai recuando ou avançando
                Segue_Objecto_CAM1(ImageFrame, Convert.ToInt32(H_Lval.Text), Convert.ToInt32(H_Hval.Text), Convert.ToInt32(S_Lval.Text), Convert.ToInt32(S_Hval.Text), Convert.ToInt32(V_Lval.Text), Convert.ToInt32(V_Hval.Text), H.Checked, S.Checked, V.Checked, Invert.Checked, Convert.ToDouble(Area.Text));
            }
        }
コード例 #2
0
ファイル: Mission3.cs プロジェクト: rafaelrmmartins/idronecup
        void Mission3_Click(object sender, System.EventArgs e)
        {
            mDrone.droneDescolar();
            mDrone.iDroneCup_Hover();

            resetDroneTrajVal();

            do
            {
                mDrone.droneMoverPRO(0.2f, 0f, -0.5f, 0f);

                EstadoDrone();
            } while(mDrone.droneObterAltitude() < 0.75f);

            resetDroneTrajVal();

            mDrone.droneMudarCamara(Drone.DroneCamera.INFERIOR);

            while (true)
            {
                //processing

                while (true) //get new image
                {
                    mDrone.imageChange += new Drone.droneImageHandler(atualizarImagemOnly);

                    if (ImageFrame.Bitmap != null)
                    {
                        break;
                    }
                }

                imgsize.X = ImageFrame.Width;
                imgsize.Y = ImageFrame.Height;

                img1 = ProImg.Deteccao_Linha(ImageFrame);

                droneTraj.ObjectTracking3(ProImg.Obj_centroid, imgsize);

                //outputs

                mDrone.droneMoverPRO(0.25f, droneTraj.Vel_y_drone, 0f, droneTraj.Vel_rot_z_drone);

                //refresh form
                pictureBox1.Image = ImageFrame.Bitmap;
                pictureBox2.Image = img1.Bitmap;

                EstadoDrone();

                //condiçao de final percurso

                img1 = ProImg.HsvROI(ImageFrame, 0, 0, 0, 0, 0, 66, false, false, true, false);

                img1 = img1.SmoothGaussian(9);

                // TODO: select area parameter for mission 4 : function of height?

                ProImg.Deteccao_Circulo(img1, ImageFrame, 100);

                if ((ProImg.Obj_centroid.X == -1) || (ProImg.Obj_centroid.Y == -1))
                {
                    resetDroneTrajVal();
                    break;
                }
            }
            while (true)     //aterragem
            {
                while (true) //get new image
                {
                    mDrone.imageChange += new Drone.droneImageHandler(atualizarImagemOnly);

                    if (ImageFrame.Bitmap != null)
                    {
                        break;
                    }
                }

                imgsize.X = ImageFrame.Width;
                imgsize.Y = ImageFrame.Height;

                // TODO: better way to check HUE, SAT and VAL
                img1 = ProImg.HsvROI(ImageFrame, 0, 0, 0, 0, 0, 66, false, false, true, false);

                img1 = img1.SmoothGaussian(9);

                // TODO: select area parameter for mission 4 : function of height?

                ProImg.Deteccao_Circulo(img1, ImageFrame, 100);

                droneTraj.ObjectTracking2(ProImg.Obj_centroid, imgsize);

                //output
                mDrone.droneMoverPRO(droneTraj.Vel_x_drone, droneTraj.Vel_y_drone, 0f, droneTraj.Vel_rot_z_drone);

                //refresh form
                pictureBox1.Image = ImageFrame.Bitmap;
                pictureBox2.Image = img1.Bitmap;

                EstadoDrone();

                //break out
                if ((Math.Abs(ProImg.Obj_centroid.X - (imgsize.X / 2)) < 10) && (Math.Abs(ProImg.Obj_centroid.Y - (imgsize.Y / 2)) < 10))
                {
                    break;
                }
            }

            resetDroneTrajVal();
            mDrone.droneAterrar();

            return;
        }