Based on the error you are getting, and the documentation for the ExhaustiveTemplateMatching call, it looks like image2
is larger than image1
. I don't think your extension method has any errors in it.
Overall, it looks like your issue is with image1
and image2
themselves. One possible solution is to add logic to determine which image is larger, and then pass that one in as the sourceImage
parameter and pass the other as the templateImage
.
I have no idea how this method handles cases where image1 is taller, but image2 is wider though...
Disclaimer: I have never used AForge; I am just gleaning I can from overall C# knowledge and a brief look at the method documentation.