unsafe public static bool IsMatch(IplImage img1, IplImage target, float threshold) { try { if (target.Width < img1.Width) { return(false); } if (target.Height < img1.Height) { return(false); } Console.WriteLine("img1:" + img1.GetElemType() + ", " + img1.Depth); Console.WriteLine("target:" + target.GetElemType() + ", " + target.Depth); // 画像マッチング var dstSize = new CvSize(target.Width - img1.Width + 1, target.Height - img1.Height + 1); using (var dst = Cv.CreateImage(dstSize, BitDepth.F32, 1)) { double min_val = 0, max_val = 0; CvPoint min_loc = CvPoint.Empty, max_loc = CvPoint.Empty; Cv.MatchTemplate(target, img1, dst, MatchTemplateMethod.CCoeffNormed); Cv.MinMaxLoc(dst, out min_val, out max_val, out min_loc, out max_loc, null); Console.WriteLine("matching: " + max_val); return(max_val >= threshold); } } catch (Exception e) { MessageBox.Show(e.ToString()); return(false); } }