嘗試在調用比較擴展方法時使用AForge.Imaging
,i am getting Template's size should be smaller or equal to source image's size
比較2位圖。AForge圖像比較
public static Boolean Compare(this Bitmap image1, Bitmap image2, double comparisionLevel, float threshold)
{
return new ExhaustiveTemplateMatching(threshold)
.ProcessImage(image1.To24bppRgbFormat(), image2.To24bppRgbFormat())[0]
.Similarity >= comparisionLevel;
}
public static Bitmap To24bppRgbFormat(this Bitmap img)
{
return img.Clone(new Rectangle(0, 0, img.Width, img.Height),
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
}
我在想什麼?
我沒有看到任何副手,看起來會導致錯誤。你確定你的擴展方法是錯誤的根源嗎?有可能擴展方法工作正常,但是'ProcessImage'不喜歡傳遞給它的值。我建議將'img.Clone'的結果設置爲局部變量,然後返回,然後嘗試調試應用程序。如果'To24bppRgbFormat'沒有拋出異常,那麼你可以看到它實際返回的值,這可能會幫助你解決問題。 –