コード例 #1
0
 private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     pictureBox1.Image.Dispose();
     try
     {
         Bitmap b = ScreenshotHandler.getWindowCapture();
         pictureBox1.Image = ImageHandler.imageResize(b, 600.0 / b.Height);
         b.Dispose();
     }
     catch { }
 }
コード例 #2
0
        private void findImg(Image <Gray, byte> target)
        {
            Image <Gray, byte>  img    = new Image <Gray, byte>(ScreenshotHandler.getWindowCapture());
            Image <Gray, float> result = new Image <Gray, float>(img.Width, img.Height);

            result = img.MatchTemplate(target, TemplateMatchingType.CcorrNormed);
            double min = 0, max = 0;
            Point  maxp = new Point(0, 0);
            Point  minp = new Point(0, 0);

            CvInvoke.MinMaxLoc(result, ref min, ref max, ref minp, ref maxp);
            Console.WriteLine(min + " " + max);
            CvInvoke.Rectangle(img, new Rectangle(maxp, new Size(target.Width, target.Height)), new MCvScalar(0, 0, 255), 3);
            pictureBox2.Image = img.ToBitmap();
        }
コード例 #3
0
        /*
         *       public static void findImg(Image<Gray, byte> target)
         *      {
         *          Image<Gray, byte> screenshot = new Image<Gray, byte>(ScreenshotHandler.getWindowCapture());
         *          Image<Gray, float> result = new Image<Gray, float>(screenshot.Width, screenshot.Height);
         *          result = screenshot.MatchTemplate(target, TemplateMatchingType.CcorrNormed);
         *          double min = 0, max = 0;
         *          Point maxp = new Point(0, 0);
         *          Point minp = new Point(0, 0);
         *          CvInvoke.MinMaxLoc(result, ref min, ref max, ref minp, ref maxp);
         *          Console.WriteLine(min + " " + max);
         *          CvInvoke.Rectangle(screenshot, new Rectangle(maxp, new Size(target.Width, target.Height)), new MCvScalar(0, 0, 255), 3);
         *          pictureBox2.Image = screenshot.ToBitmap();
         *
         *      }
         */
        public static Point findImgLocation(string path)
        {
            Image <Gray, byte>  target     = new Image <Gray, byte>(path);
            Image <Gray, byte>  screenshot = new Image <Gray, byte>(ScreenshotHandler.getWindowCapture());
            Image <Gray, float> result     = new Image <Gray, float>(screenshot.Width, screenshot.Height);

            result = screenshot.MatchTemplate(target, TemplateMatchingType.CcorrNormed);
            double min = 0, max = 0;
            Point  maxp = new Point(0, 0);
            Point  minp = new Point(0, 0);

            CvInvoke.MinMaxLoc(result, ref min, ref max, ref minp, ref maxp);
            Console.WriteLine(min + " " + max);

            screenshot.Dispose();
            result.Dispose();

            if (max < 0.99)
            {
                throw new TargetNotFoundException();
            }
            return(new Point(maxp.X + target.Width / 2, maxp.Y + target.Height / 2));
        }