Example #1
0
        private void CreateVisionProcess(ref SettingsRepository.SettingsRepository setRepo)
        {
            colorVideoSource = new ColorVideoSource();
            colorVideoSource.ResultReady += DisplayVideo;

            Hsv min = new Hsv((int)setRepo.Get("min-h")
                              , (int)setRepo.Get("min-s")
                              , (int)setRepo.Get("min-v")),
                max = new Hsv((int)setRepo.Get("max-h")
                              , (int)setRepo.Get("max-s")
                              , (int)setRepo.Get("max-v"));

            filter = new HsvFilter(colorVideoSource, min, max);
            roadDetector = new RoadCenterDetector(filter);
            // roadDetector.Perceptor.perspectiveTransform.ResultReady += DisplayVideo;
            visRoad = new VisualiseSimpleRoadModel(roadDetector.Perceptor.roadDetector);
            invPerp = new PerspectiveCorrectionRgb(visRoad, CamModel.dstPerspective, CamModel.srcPerspective);

            brain = new FollowTheRoadBrainCentre(roadDetector, carController);
            brain.evNewTargetWheelAngeCalculated += new FollowTheRoadBrainCentre.newTargetWheelAngeCalculatedEventHandler(brain_evNewTargetWheelAngeCalculated);
            brain.evNewTargetSpeedCalculated += new FollowTheRoadBrainCentre.newTargetSpeedCalculatedEventHandler(brain_evNewTargetSpeedCalculated);

            roadDetector.Perceptor.laneDetector.Tau            = (int) setRepo.Get("tau");
            roadDetector.Perceptor.laneDetector.Threshold      = (byte)((int)setRepo.Get("threshold"));
            roadDetector.Perceptor.laneDetector.VerticalOffset = (int) setRepo.Get("v-offset");

            visRoad.ResultReady += DisplayVideo;
            invPerp.ResultReady += DisplayVideo;
            colorVideoSource.Start();
        }
Example #2
0
        private void PrepareVisionProcess()
        {
            colorVideoSource = new ColorVideoSource(getVideoSource());
            colorVideoSource.ResultReady += DisplayVideo;

            // light green lines
            Hsv minColor = new Hsv(95 / 2, 0.6 * 255, 0.5 * 255);
            Hsv maxColor = new Hsv(180 / 2, 255, 0.74 * 255);

            filter = new HsvFilter(colorVideoSource, minColor, maxColor);
            roadDetector = new RoadCenterDetector(filter);
            // roadDetector.Perceptor.perspectiveTransform.ResultReady += DisplayVideo;

            // road center points, kalman filtered
            kalmanFilteredRoadCenter = new DrawColoredPointSets(roadDetector);
            kalmanFilteredRoadCenter.ResultReady += DisplayVideo;
            kalmanFilteredRoadCenter.Active = true;

            filtered = new DrawPoints(roadDetector.Perceptor.laneDetector);
            filtered.ResultReady += DisplayVideo;
            filtered.Active = true;

            visRoad = new VisualiseSimpleRoadModel(roadDetector.Perceptor.roadDetector);
            visRoad.ResultReady += DisplayVideo;

            invPerp = new PerspectiveCorrectionRgb(visRoad, CamModel.dstPerspective, CamModel.srcPerspective);
            //invPerp = new PerspectiveCorrectionRgb(colorVideoSource, CamModel.srcPerspective, CamModel.dstPerspective);
            invPerp.ResultReady += DisplayVideo;

            roadDetector.RoadCenterSupply += roadCenter;
        }