コード例 #1
0
 public static VectorOfVectorOfPoint findApproxContours(IImage image, int threshold = 140)
 {
     return(ContourFinder.getApproxContour(
                ContourFinder.findContours(
                    ImageTransformAlgorithms.getThreshold(
                        ImageTransformAlgorithms.pyramideDec(image), threshold))));
 }
コード例 #2
0
 private void findContoursButton_Click(object sender, EventArgs e)
 {
     try
     {
         imageBox2.Image = Drawer.drawContour(imageBox1.Image,
                                              ContourFinder.findApproxContours(imageBox1.Image, int.Parse(textBox1.Text)));
     }
     catch (FormatException ex)
     {
         MessageBox.Show(ex.Message, "Fromat Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     catch (NullReferenceException ex)
     {
         MessageBox.Show(ex.Message, "Null Reference Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
コード例 #3
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                String currentContuor = comboBox1.SelectedItem.ToString();

                if (currentContuor == "Triangles")
                {
                    imageBox2.Image = Drawer.drawContour(imageBox1.Image,
                                                         ContourFinder.getTriangles(
                                                             ContourFinder.findApproxContours(imageBox1.Image, int.Parse(textBox1.Text)),
                                                             int.Parse(textBox2.Text)
                                                             )
                                                         );
                }
                if (currentContuor == "Rectangles")
                {
                    imageBox2.Image = Drawer.drawContour(imageBox1.Image,
                                                         ContourFinder.getRectangles(
                                                             ContourFinder.findApproxContours(imageBox1.Image, int.Parse(textBox1.Text)),
                                                             int.Parse(textBox2.Text)
                                                             )
                                                         );
                }
                if (currentContuor == "Circles")
                {
                    imageBox2.Image = Drawer.drawContour(imageBox1.Image, ContourFinder.getCircles(imageBox1.Image, int.Parse(textBox1.Text)));
                }
            }
            catch (FormatException ex)
            {
                MessageBox.Show(ex.Message, "Fromat Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (NullReferenceException ex)
            {
                MessageBox.Show(ex.Message, "Null Reference Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }