示例#1
0
文件: VideoForm.cs 项目: zyh329/adas
        private void UpdateImage(object sender, EventArgs eventArgs)
        {
            if (capture_.Grab())
            {
                var frame  = capture_.QueryFrame();
                var result = ProcessHoughTest(frame);
                if (result.SolidLines.Length > 1)
                {
                    windows_ = WindowFlow.Compute(frame.Size, result.SolidLines);
                }
                if (windows_ != null)
                {
                    WindowFlow.DrawWindows(frame, windows_);
                }
                pictureBox1.Image = frame.Bitmap;

                frameCount_++;
                frameLabel_.Text = "frame: " + frameCount_;

                Thread.Sleep(10);
            }
            else
            {
                Application.Idle -= UpdateImage;
            }
        }
示例#2
0
文件: Program.cs 项目: zyh329/adas
        public static void ProcessCarDetectionTest()
        {
            var image = new Image <Gray, byte>("Images/disparity.png");

            var left  = new LineSegment2D(new Point(61, 221), new Point(121, 175));
            var right = new LineSegment2D(new Point(253, 221), new Point(209, 175));

            ////*****draw lines*****
            //var red = new Bgr(Color.Red);
            //image.Draw(left, red, 1);
            //image.Draw(right, red, 1);

            var original = CalculateHistogram(image);
            var cutted   = new float[256];

            Array.Copy(original, cutted, 256);

            var windows   = WindowFlow.Compute(image.Size, new[] { left, right });
            var allValues = new List <float[]>();

            int counter = 0;

            foreach (var window in windows)
            {
                counter++;
                image.ROI = window;
                var values = CalculateHistogram(image);
                for (var i = 0; i < original.Length; ++i)
                {
                    if (original[i] > 0)
                    {
                        values[i] = (original[i] - values[i]) / original[i];
                    }
                    else
                    {
                        values[i] = 1.0f;
                    }
                }
                if (AnalyzeHistogram(values))
                {
                    Console.WriteLine(counter);
                }

                allValues.Add(values);
            }

            //PrintData(allValues);


            //ImageViewer.Show(image);
        }