コード例 #1
0
        public static void FastRandomizedCircleDetectionMain(string file)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            Edge edge = new Edge(file, true);
            FastRandomizedCircleDetection frandCircleDetect = new FastRandomizedCircleDetection(edge, 30, 150, 30, 1, 0.015, 0.035, 0.3, EdgeType.MORPHOLOGICAL_THINNING, false);
            List <int[]> circles = frandCircleDetect.DetectCircles();

            stopWatch.Stop();
            Console.WriteLine("Elapsed Time: " + stopWatch.ElapsedMilliseconds.ToString() + "ms");
            Console.WriteLine("Edges Count :" + edge.GetEdgePointsCount());

            if (circles.Count != 0)
            {
                Console.WriteLine(circles[0][0]);
                Console.WriteLine(circles[0][1]);
                Console.WriteLine(circles[0][2]);
                Image <Bgr, Byte> image = edge.GetOriginalImage();
                CvInvoke.Circle(image, new Point(circles[0][0], circles[0][1]), circles[0][2], new MCvScalar(1, 123, 100), 5);
                ImageView.imShow(image);
            }
            else
            {
                Console.WriteLine("No Circle Found");
            }
            // ImageView.imShow(edge.getBinaryEdgeImage());
        }
コード例 #2
0
        private static void Main(string[] args)
        {
            CvInvoke.UseOptimized = true;
            CvInvoke.UseOpenCL    = true;
            String filePath = OpenFile(@"/test images");

            using (Edge edge = new Edge(filePath, true))
            {
                RandomizedCircleDetection randmoizedCircleDetect = new RandomizedCircleDetection(edge, 30, 2000, 15, 1,
                                                                                                 0.01, 0.08, 0.47, EdgeType.CANNY_EDGE, false);
                List <int[]> circles = randmoizedCircleDetect.DetectCircles();
                if (circles.Count != 0)
                {
                    Console.WriteLine("Randomized Circle Detection");
                    Console.WriteLine("CX, CY, R");
                    Console.Write(circles[0][0]);
                    Console.Write(", ");
                    Console.Write(circles[0][1]);
                    Console.Write(", ");
                    Console.Write(circles[0][2]);
                    Console.WriteLine(" ");

                    Image <Bgr, byte> image = edge.GetOriginalImage();
                    CvInvoke.Circle(image, new Point(circles[0][0], circles[0][1]), circles[0][2],
                                    new MCvScalar(1, 123, 100), 5);
                    ImageView.imShow(image);
                }
                else
                {
                    Console.WriteLine("No Circle Found");
                    ImageView.imShow(edge.GetBinaryEdgeImage());
                }
                FastRandomizedCircleDetection frandCircleDetect = new FastRandomizedCircleDetection(edge, 30, 2000, 15, 1,
                                                                                                    0.01, 0.08, 0.47, EdgeType.CANNY_EDGE, false);
                circles = frandCircleDetect.DetectCircles();
                if (circles.Count != 0)
                {
                    Console.WriteLine("Fast Randomized Circle Detection");
                    Console.WriteLine("CX, CY, R");
                    Console.Write(circles[0][0]);
                    Console.Write(", ");
                    Console.Write(circles[0][1]);
                    Console.Write(", ");
                    Console.Write(circles[0][2]);
                    Console.WriteLine(" ");

                    Image <Bgr, byte> image = edge.GetOriginalImage();
                    CvInvoke.Circle(image, new Point(circles[0][0], circles[0][1]), circles[0][2],
                                    new MCvScalar(1, 123, 100), 5);
                    ImageView.imShow(image);
                }
                else
                {
                    Console.WriteLine("No Circle Found");
                    ImageView.imShow(edge.GetBinaryEdgeImage());
                }
            }
        }