示例#1
1
        private void DrawDebugInfo(Bitmap frame, VisionResults results)
        {
            using (var g = Graphics.FromImage(frame))
            {
                /*{
                    var thresholdString = string.Format("Threshold: {0}", HoughTransform.CannyThreshold);
                    var linkingString = string.Format("Linking: {0}", HoughTransform.CannyThresholdLinking);

                    g.FillRectangle(Brushes.White, 5, 5, 100, 50);
                    g.DrawString(thresholdString, SystemFonts.DefaultFont, Brushes.Crimson, new PointF(10, 10));
                    g.DrawString(linkingString, SystemFonts.DefaultFont, Brushes.Crimson, new PointF(10, 30));
                }*/

                if (showCircles)
                    foreach (var circle in results.Circles)
                    {
                        g.DrawEllipse(ellipsePen, circle.X - circle.Radius, circle.Y - circle.Radius, circle.Radius * 2, circle.Radius * 2);
                        g.DrawString(circle.Intensity.ToString(), SystemFonts.DefaultFont, Brushes.Orange, circle.X, circle.Y);
                    }

                if (showLines)
                    foreach (var line in results.Lines)
                    {
                        g.DrawLine(linePen, line.P1, line.P2);
                        g.DrawString(line.Length.ToString("0.00"), SystemFonts.DefaultFont, Brushes.OrangeRed, line.P2);
                    }

                if (results.TrackingBall)
                {
                    g.DrawRectangle(camshiftPen, results.TrackWindow);
                    g.DrawLine(camshiftPen, results.TrackCenter, Point.Add(results.TrackCenter, new Size(1, 1)));
                }
            }
        }
示例#2
0
        public MainVideoProcessor(int camIndex = 0)
        {
            results = new VisionResults();
            camshift = new Camshift();

            Feed = new VideoFeed2(0);
            //Feed = VideoFeed.FromCamIndex(camIndex);
            //Feed = new VideoFeed(VideoFeed.Sample7);

            //var timer = new Timer(1000);
            //timer.Elapsed += (sender, args) => framesPerSecond = Feed.FramesReceived;
            //timer.Start();
        }