Пример #1
0
        private static bool TryFindCircleInFullFrame(IndicatorData data, out CircleF ret)
        {
            ret = default(CircleF);

            if (RollIndicator.TryFindRollCircleInFullFrame(data, out var circle))
            {
                circle.Center = new PointF(circle.Center.X + 140, circle.Center.Y + 70);
                circle.Radius = 55;
                var firstCrop = Math2.CropCircle(circle, 10);
                var focus     = data.Frame.SafeCopy(firstCrop);

                var circles = CvInvoke.HoughCircles(focus.Convert <Hsv, byte>()[2], HoughType.Gradient, 2.0, 20, 10, 180, 45, 55);
                if (circles.Length == 1)
                {
                    circles[0].Center = circles[0].Center.Add(firstCrop.Location);
                    circles[0].Radius = 50;
                    ret = circles[0];
                    return(true);
                }
            }
            return(false);
        }
Пример #2
0
        public double ReadValue(IndicatorData data, DebugState debugState)
        {
            if (RollIndicator.TryFindRollCircleInFullFrame(data, out var circle))
            {
                var firstCrop = new Rectangle((int)circle.Center.X + 500, (int)circle.Center.Y - 180, 100, 150);
                var focus     = data.Frame.SafeCopy(firstCrop);

                var vs_blackImg = focus.Convert <Hsv, byte>().InRange(new Hsv(0, 120, 0), new Hsv(180, 255, 255));

                var blobs = Utils.DetectAndFilterBlobs(vs_blackImg.PyrUp().PyrDown(), 1500, 2500);
                if (blobs.Any())
                {
                    var landingGearFrame = focus.Copy(blobs.First().BoundingBox);

                    var hsv       = landingGearFrame.Convert <Hsv, byte>();
                    var black_img = hsv.DynLowInRange(dyn_lower, new Hsv(180, 255, 255));
                    debugState.Add(landingGearFrame);
                    debugState.Add(black_img);

                    blobs = Utils.DetectAndFilterBlobs(black_img, 200, 1500);
                    if (blobs.Any())
                    {
                        var blob = blobs.First();
                        var ret  = (landingGearFrame.Height / 2) - blob.Centroid.Y;

                        if (ret > 4)
                        {
                            return(1);
                        }
                        else if (ret < -4)
                        {
                            return(-1);
                        }
                    }
                }
            }
            return(double.NaN);
        }
Пример #3
0
        private static bool TryFindCircleInFullFrame(IndicatorData data, out CircleF ret)
        {
            ret = default(CircleF);

            if (RollIndicator.TryFindRollCircleInFullFrame(data, out var circle))
            {
                circle.Center = new PointF(circle.Center.X + 1055, circle.Center.Y - 20);
                circle.Radius = 70;
                var firstCrop = Math2.CropCircle(circle, 40);
                var focus     = data.Frame.SafeCopy(firstCrop);
                var focusHsv  = focus.Convert <Hsv, byte>().PyrUp().PyrDown();

                var circles = CvInvoke.HoughCircles(focusHsv[2], HoughType.Gradient, 2.0, 80, 10, 80, 60, 80);
                if (circles.Length == 1)
                {
                    var circ = circles[0];
                    circles[0].Center = circles[0].Center.Add(firstCrop.Location);
                    circles[0].Radius = 64;
                    ret = circles[0];
                    return(true);
                }
            }
            return(false);
        }