Example #1
0
        public void cuda_MatchTemplate()
        {
            Mat  image = Image("lenna.png", ImreadModes.Grayscale);
            Mat  templ = image.RowRange(60, 80).ColRange(60, 80);
            Size size  = image.Size();

            using (GpuMat g_src = new GpuMat(size, image.Type()))
                using (GpuMat d_dst = new GpuMat()) {
                    g_src.Upload(image);

                    TemplateMatching alg = TemplateMatching.create(g_src.Type(), TemplateMatchModes.CCoeff);

                    GpuMat g_templ = new GpuMat();
                    g_templ.Upload(templ);
                    alg.match(g_src, g_templ, d_dst);

                    Mat dst_gold = new Mat();
                    Cv2.MatchTemplate(image, templ, dst_gold, TemplateMatchModes.CCoeff);

                    ImageEquals(g_templ, templ);
                    ShowImagesWhenDebugMode(g_templ, templ);
                }
        }