public void StartRecognition(RangeImage rangeImage)
        {
            rangeData = rangeImage;
            height = rangeImage.Height;
            width = rangeImage.Width;

            bm = new Bitmap(width, height);
            g = Graphics.FromImage(bm);
            image.BackgroundImage = bm;
            image.BackgroundImageLayout = ImageLayout.None;

            image.Size = new Size(width, height);

            g.Clear(Color.White);

            SphereRecognition sr = new SphereRecognition();

            //System.Windows.Forms.MessageBox.Show("W/H = " + width + "/" + height);

            image.Bounds = new Rectangle(0, 0, width, height);

            paintImage();

            edges = sr.detectEdges(rangeData, float.Parse(conf1.Text));

            //doFix();

            /**/
            paintEdges();

            List<Sphere> spheres = sr.FindSpheres(rangeData, edges, int.Parse(maxRadius.Text), int.Parse(minRadius.Text), float.Parse(conf1.Text), float.Parse(conf2.Text));

            Sphere actual;
            for (int i = 0; i < spheres.Count; i++)
            {
                actual = spheres[i];
                //int tmp = actual.center.X;
                actual.center.Y = height - actual.center.Y;
                //actual.center.Y = tmp;
                //actual.center.X += (int)(actual.radius*1.35f);
                g.DrawEllipse(Pens.Blue, (int)actual.center.X - actual.radius, ((int)actual.center.Y - actual.radius), (int)actual.radius * 2, (int)actual.radius * 2);
                g.DrawLine(Pens.Blue, (actual.center.X - 1), (actual.center.Y - 1) - 5, (actual.center.X - 1), (actual.center.Y - 1) + 5);
                g.DrawLine(Pens.Blue, (actual.center.X - 1) - 5, (actual.center.Y - 1), (actual.center.X - 1) + 5, (actual.center.Y - 1));
                image.Refresh();
                //g.DrawEllipse(Pens.Blue, (int)actual.center.Y - actual.radius, ((int)actual.center.X - actual.radius), (int)actual.radius * 2, (int)actual.radius * 2);
                //g.DrawLine(Pens.Blue, (actual.center.Y - 1), (actual.center.X - 1) - 5, (actual.center.Y - 1), (actual.center.X - 1) + 5);
                //g.DrawLine(Pens.Blue, (actual.center.Y - 1) - 5, (actual.center.X - 1), (actual.center.Y - 1) + 5, (actual.center.X - 1));
                float formula2 = ((17f / 9 * (float)actual.radius) - 94f / 9f) / 1000f;
                String algo = "haha " + actual.radius * (Math.Cos(89.9 * (Math.PI / 180)) * actual.avgDistance) + "\n" + (actual.midPoints - actual.avgDistance) + "\n" + Math.Abs(actual.midPoints - actual.avgDistance) + "\n" + formula2 + "\n" + (Math.Abs(actual.midPoints - actual.avgDistance) - formula2);
                //System.Windows.Forms.MessageBox.Show("ABSOLUTE=\nX="+actual.absolutePosition.X+"\nY="+actual.absolutePosition.Y+"\nZ="+actual.absolutePosition.Z+"\n\nx=" + actual.center.X + "\ny=" + actual.center.Y + "\n\nR=" + actual.radius + "\nDiffC=" + actual.diffCircumference + "\nS=" + actual.score + "\nAVGD=" + actual.avgDistance + "\nAVGM=" + actual.midPoints + "\nAVGE=" + actual.avgEdges + "\n\n\n" + algo);
                //paintImage();
                //paintEdges();
            }
            /**/
        }
Exemple #2
0
        /**
         * @brief Event handler. Called by button7 for click events.
         * @param sender An object - Source of the event
         * @param e An EventArgs - Event Information
           */
        private void button7_Click(object sender, EventArgs e)
        {
            SphereRecognition sr = new SphereRecognition();
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                sr = new SphereRecognition();

                hm = new HeightMap(RangeImage.Read(openFileDialog1.FileName));
                hm.createMap();
                heightMap = hm.bool_grid;

                detectedSpheres = sr.FindSpheres(RangeImage.Read(openFileDialog1.FileName), null, 35, 7, 0.2f, 70f);
                spherePositions.Clear();
                sphereRadii.Clear();
                detectedDrones.Clear();

                prepareSpheres();
                findDrones();
            }
        }