Class OpenCVTemplateMatcher

  • All Implemented Interfaces:
    TemplateMatcher

    @Component
    public class OpenCVTemplateMatcher
    extends Object
    implements TemplateMatcher
    Implementation of TemplateMatcher using OpenCV on the client

    This class provides methods to check whether a given image (template) is part of another one (target). We use a simple (yet effective) way to detect the template image in various sizes by scaling the target up and down to a minimum and maximum size.

    We return on the first match that exceeds the specific threshold (matching quality). This means that it is not necessarily the best possible match.

    • Constructor Detail

      • OpenCVTemplateMatcher

        @Autowired
        public OpenCVTemplateMatcher​(ImageUtils imageUtils)
        Parameters:
        imageUtils - ImageUtils
    • Method Detail

      • match

        public Match match​(String targetFile,
                           String templateFile,
                           double threshold)
        Description copied from interface: TemplateMatcher
        Check whether the template appears anywhere within the target image.
        Specified by:
        match in interface TemplateMatcher
        Parameters:
        targetFile - path to the target file
        templateFile - path to the template file
        threshold - matching threshold
        Returns:
        Match
      • match

        public Match match​(String targetFile,
                           String templateFile,
                           double threshold,
                           String description)
        Description copied from interface: TemplateMatcher
        Check whether the template appears anywhere within the target image.
        Specified by:
        match in interface TemplateMatcher
        Parameters:
        targetFile - path to the target file
        templateFile - path to the template file
        threshold - matching threshold
        description - of the check
        Returns:
        Match