Exemple #1
0
        public static double TemplateMatchOnROI(Image <Gray, Byte> template, Rectangle roi, Image <Gray, Byte> image)
        {
            Image <Gray, Byte> source = new Image <Gray, byte>(ImgProc.CropImage(image.ToBitmap(), roi));

            if (source.Width >= template.Width && source.Height >= template.Height)
            {
                using (Image <Gray, float> result = source.MatchTemplate(
                           template, Emgu.CV.CvEnum.TemplateMatchingType.CcorrNormed))
                {
                    double[] minValues;
                    double[] maxValues;
                    Point[]  minLocations;
                    Point[]  maxLocations;

                    result.MinMax(out minValues, out maxValues,
                                  out minLocations, out maxLocations);

                    if (minValues.Length > 0)
                    {
                        return(maxValues[0] * 100.0);
                    }


                    return(0.0);
                }
            }

            return(0.0);
        }
Exemple #2
0
        public static void ForTemplateSaving(string dir, Bitmap filtered, Rectangle rect)
        {
            Bitmap filteredCropped = ImgProc.CropImage(filtered, rect);

            filteredCropped.Save(dir);
        }