Example #1
0
        private float getFishProgress()
        {
            ms2.GrabImage(512, 747, 262, 1);
            Image <Hsv, byte> yellowbox = new Image <Hsv, byte>(300, 1);

            yellowbox = new Mat(ms2.imgGrab.ToMat(), new Rectangle(0, 0, 262, 1)).ToImage <Hsv, byte>();
            Hsv lowerLimit            = new Hsv(45, 175, 175);
            Hsv upperLimit            = new Hsv(62, 255, 255);
            Image <Gray, byte> result = yellowbox.InRange(lowerLimit, upperLimit);
            // CvInvoke.Imshow("debug", yellowbox);
            //CvInvoke.WaitKey(1);
            float percent = result.CountNonzero()[0] / 262.0f;

            return(percent);
        }
Example #2
0
        public bool OnFire()
        {
            ms2.GrabImage(690, 816, 170, 29);
            Mat    temp   = new Mat(ms2.imgGrab.ToMat(), new Rectangle(0, 0, 170, 29));
            GpuMat result = new GpuMat(temp);
            GpuMat output = new GpuMat(temp);

            temp.Dispose();

            ms2.ctm.Match(result, fireimg, output);
            double minval = 0, maxval = 0;
            Point  maxloc = new Point(), minloc = new Point();

            CudaInvoke.MinMaxLoc(output, ref minval, ref maxval, ref minloc, ref maxloc);
            if (maxval > .9f)
            {
                return(true);
            }
            return(false);
        }