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