Class OpenCVPatternMatcher
- All Implemented Interfaces:
PatternMatcher
This implementation uses Sikuli's Finder (which wraps OpenCV) for pattern matching operations. It is completely independent of the Find action and other high-level Brobot components, providing pure pattern matching functionality.
Key characteristics:
- No dependencies on Find or Action classes
- Thread-safe through stateless operations
- Properly manages Finder resources
- Handles pattern size validation
- Since:
- 2.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.github.jspinak.brobot.core.services.PatternMatcher
PatternMatcher.MatchOptions, PatternMatcher.MatchResult
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindPatterns
(BufferedImage screen, Pattern pattern, PatternMatcher.MatchOptions options) Finds patterns within a screen image.findPatternsInRegion
(BufferedImage screen, Pattern pattern, int regionX, int regionY, int regionWidth, int regionHeight, PatternMatcher.MatchOptions options) Finds patterns within a specific region of the screen.Gets the name of this pattern matcher implementation.boolean
supportsPattern
(Pattern pattern) Checks if this matcher supports a specific pattern type.
-
Constructor Details
-
OpenCVPatternMatcher
public OpenCVPatternMatcher()
-
-
Method Details
-
findPatterns
public List<PatternMatcher.MatchResult> findPatterns(BufferedImage screen, Pattern pattern, PatternMatcher.MatchOptions options) Description copied from interface:PatternMatcher
Finds patterns within a screen image.This method performs the core pattern matching operation, searching for occurrences of the pattern within the screen image. The implementation may use any pattern matching algorithm (template matching, feature matching, etc.).
- Specified by:
findPatterns
in interfacePatternMatcher
- Parameters:
screen
- The screen image to search withinpattern
- The pattern to search foroptions
- Configuration for the matching operation- Returns:
- List of match results, empty if no matches found
-
findPatternsInRegion
public List<PatternMatcher.MatchResult> findPatternsInRegion(BufferedImage screen, Pattern pattern, int regionX, int regionY, int regionWidth, int regionHeight, PatternMatcher.MatchOptions options) Description copied from interface:PatternMatcher
Finds patterns within a specific region of the screen.This method optimizes pattern matching by searching only within a specified region of the screen image, improving performance for targeted searches.
- Specified by:
findPatternsInRegion
in interfacePatternMatcher
- Parameters:
screen
- The screen image to search withinpattern
- The pattern to search forregionX
- X coordinate of the search regionregionY
- Y coordinate of the search regionregionWidth
- Width of the search regionregionHeight
- Height of the search regionoptions
- Configuration for the matching operation- Returns:
- List of match results, empty if no matches found
-
supportsPattern
Description copied from interface:PatternMatcher
Checks if this matcher supports a specific pattern type.This allows for specialized matchers that only handle certain types of patterns (e.g., text patterns, color patterns).
- Specified by:
supportsPattern
in interfacePatternMatcher
- Parameters:
pattern
- The pattern to check- Returns:
- true if this matcher can handle the pattern type
-
getImplementationName
Description copied from interface:PatternMatcher
Gets the name of this pattern matcher implementation.Used for logging and debugging to identify which matcher is being used.
- Specified by:
getImplementationName
in interfacePatternMatcher
- Returns:
- Implementation name (e.g., "OpenCV", "Sikuli", "Mock")
-