我正在尝试使用AForge库在图像(模板匹配)中找到图像。
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
但是我得到一个GDI+ Exception
System.Runtime.InteropServices.ExternalException
Generic GDI+ Exception.
(此代码是从TemplateMatching示例here复制的)
注意:此代码段在BackgroundWorker
内运行