0

I am trying to find a image within an image (Template matching) with the AForge library.

                ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching(0.921f);
                // find all matchings with specified above similarity

                TemplateMatch[] matchings = tm.ProcessImage(dest.Bitmap, oI.Bitmap);
                // highlight found matchings

                BitmapData data = dest.Bitmap.LockBits(
                    new Rectangle(0, 0, dest.Bitmap.Width, dest.Bitmap.Height),
                    ImageLockMode.ReadWrite, dest.Bitmap.PixelFormat);
                List<Point> points = new List<Point>();
                foreach (TemplateMatch m in matchings)
                {
                    points.Add(new Point(m.Rectangle.X, m.Rectangle.Y));

                }
                dest.Bitmap.UnlockBits(data); << Error

However I get an GDI+ Exception

System.Runtime.InteropServices.ExternalException
Generic GDI+ Exception.

(This code was copied from the TemplateMatching example here)

Note: This code snippet is running within a BackgroundWorker

0x45
  • 779
  • 3
  • 7
  • 26
  • 1
    Not really clear. Why are locking that bitmap in memory and then, from this code, you're doing nothing with it? There are some parts missing. – Jimi Jul 20 '18 at 07:35
  • Yeeah... as it is shown, that whole operation is useless. Give more info on what actually happens. – Nyerguds Jul 26 '18 at 14:13

0 Answers0