Pattern Creation Tools Guide
Overviewโ
This guide helps you choose the best tool for creating pattern images that work with Brobot's pattern matching system. The choice of pattern creation tool directly impacts the accuracy of your UI automation.
Recommended Toolsโ
๐ Optimal Tools for Pattern Creationโ
These tools provide the best pattern matching during runtime automation:
1. Windows Snipping Tool (RECOMMENDED)โ
- Resolution: 1920x1080 (physical)
- Runtime Match Rate: 95-100% with Brobot's JAVACV_FFMPEG capture
- Platform: Windows only
- Why it's best: Produces the cleanest, artifact-free patterns
- How to use:
- Press
Win + Shift + S
to open Snipping Tool - Select the area you want to capture
- Save as PNG in your project's
images/
directory
- Press
2. macOS Screenshot Toolโ
- Platform: macOS
- Runtime Match Rate: 95-100%
- How to use: Press
Cmd + Shift + 4
3. Linux Screenshot Toolsโ
- Platform: Linux
- Runtime Match Rate: 95-100%
- Tools: GNOME Screenshot or Spectacle
โ Alternative Tools (Lower Match Rates)โ
SikuliX IDEโ
- Resolution: Variable (depends on DPI settings)
- Runtime Match Rate: 70-80% (can be used for testing similarity)
- Platform: Cross-platform
- Use case: Testing similarity thresholds, not for pattern creation
Brobot FFmpeg Toolโ
- Resolution: 1920x1080 (physical)
- Runtime Match Rate: 70-80% when used for patterns
- Platform: Cross-platform
- Note: Better for testing than pattern creation
โ ๏ธ Not Recommended (< 70% Similarity)โ
- Screenshot tools that apply compression or filters
- Browser-based screenshot extensions
- Tools that capture at non-standard resolutions
- Robot-based custom tools (typically 59-69% similarity)
Brobot Configurationโ
Default Configuration (Optimal)โ
The default Brobot configuration is optimized for patterns created with Windows Snipping Tool, SikuliX IDE, or Brobot FFmpeg Tool:
# Already configured in brobot-defaults.properties
brobot.capture.provider=JAVACV_FFMPEG
brobot.dpi.disable=true
brobot.dpi.resize-factor=1.0
This configuration:
- Captures at physical resolution (1920x1080)
- Disables DPI awareness to avoid scaling issues
- Uses no pattern scaling for 1:1 pixel matching
- Provides 100% similarity with recommended tools
Alternative Configuration (For Logical Resolution Tools)โ
If you're using tools that capture at logical resolution (1536x864 with 125% DPI scaling):
# application.properties
brobot.capture.provider=SIKULIX
brobot.dpi.disable=false
brobot.dpi.resize-factor=1.0
Pattern Creation Workflowโ
Step 1: Choose Your Toolโ
- For best results: Use OS native screenshot tools
- Windows: Windows Snipping Tool (Win+Shift+S)
- macOS: Built-in screenshot (Cmd+Shift+4)
- Linux: GNOME Screenshot or Spectacle
- For testing patterns: Use Brobot Pattern Capture Tool
- If you have existing patterns: Test their match rates and consider recapturing with native tools
Step 2: Capture Patternsโ
- Ensure your display is at the target resolution
- Capture UI elements with your chosen tool
- Save as PNG files (avoid JPEG to prevent compression artifacts)
- Use descriptive names:
button-submit.png
,field-username.png
Step 3: Organize Patternsโ
your-project/
โโโ images/
โ โโโ login-page/
โ โ โโโ button-login.png
โ โ โโโ field-username.png
โ โ โโโ field-password.png
โ โโโ main-menu/
โ โโโ menu-file.png
โ โโโ menu-edit.png
Step 4: Verify Pattern Matchingโ
// Test your patterns
@Autowired
private Action action;
StateImage pattern = new StateImage.Builder()
.withImage("button-login.png")
.build();
ActionResult result = action.find(pattern);
System.out.println("Similarity: " + result.getMaxSimilarity());
// Should be > 0.94 for optimal tools
Troubleshootingโ
Low Similarity Scoresโ
If you're getting similarity scores below 90%:
-
Check Resolution Mismatch
- Pattern: 1920x1080, Capture: 1536x864 โ ~77% similarity
- Solution: Use matching capture provider or enable scaling
-
Check DPI Settings
# In your application.properties
brobot.dpi.disable=true # For physical resolution -
Verify Tool Output
- Some tools apply compression or filters
- Always save as PNG, not JPEG
- Check file size - unusually small files may be compressed
Pattern Not Foundโ
-
Lower similarity threshold if needed:
brobot.action.similarity=0.85 # Default is 0.95
-
Check if pattern is unique enough:
- Avoid capturing too small areas
- Include distinctive features
- Avoid areas with changing content
Resolution Compatibility Tableโ
Pattern Creation Tool | Best Brobot Provider | Runtime Match Rate | Recommendation |
---|---|---|---|
Windows Snipping Tool | JAVACV_FFMPEG | 95-100% | RECOMMENDED |
macOS Screenshot | JAVACV_FFMPEG | 95-100% | RECOMMENDED |
Linux Screenshot | JAVACV_FFMPEG | 95-100% | RECOMMENDED |
Brobot FFmpeg Tool | JAVACV_FFMPEG | 70-80% | Testing only |
SikuliX IDE | JAVACV_FFMPEG | 70-80% | Testing only |
Best Practicesโ
DO:โ
- โ Use PNG format for patterns
- โ Capture at the same resolution you'll run automation
- โ Include unique visual elements in patterns
- โ Test patterns immediately after creation
- โ Organize patterns by screen/state
DON'T:โ
- โ Use JPEG format (compression artifacts)
- โ Capture patterns with transparency
- โ Include dynamic content (timestamps, counters)
- โ Make patterns too small (< 20x20 pixels)
- โ Mix patterns from different tools without testing
Platform-Specific Notesโ
Windowsโ
- Windows Snipping Tool is built-in and optimal
- Captures at physical resolution regardless of DPI scaling
- Perfect compatibility with default Brobot configuration
macOSโ
- Use SikuliX IDE for best results
- Built-in screenshot tool may not capture at correct resolution
- Verify resolution before creating many patterns
Linuxโ
- SikuliX IDE recommended
- Native screenshot tools vary by distribution
- Test compatibility before creating pattern library
WSL (Windows Subsystem for Linux)โ
โ ๏ธ CRITICAL LIMITATION: WSL cannot capture the Windows desktop
- Pattern matching will NOT work in WSL - captures return black/empty images
- Development only - Use WSL for coding, not for running pattern matching
- Solutions:
- Run Brobot on Windows directly (use PowerShell or Command Prompt)
- Use mock mode for testing in WSL (
brobot.mock=true
) - Create patterns on Windows, test on Windows
Migration Guideโ
From Existing Patternsโ
If you have patterns created with other tools:
-
Identify pattern resolution:
# Check image properties
file pattern.png
# Or use image viewer to check dimensions -
Adjust Brobot configuration:
- 1920x1080 patterns โ Use default configuration
- 1536x864 patterns โ Switch to SIKULIX provider
- Other resolutions โ May need custom scaling
-
Test and verify:
// Run similarity test
PatternFindOptions options = new PatternFindOptions.Builder()
.setSimilarity(0.7) // Start low for testing
.build();
Frequently Asked Questionsโ
Q: Why do different tools have different similarity scores?โ
A: Tools capture screens differently - some use logical resolution (DPI-aware), others use physical resolution. Rendering engines also differ slightly between tools.
Q: Can I mix patterns from different tools?โ
A: Not recommended. Stick to one tool for consistency. If you must mix, group patterns by tool and adjust configuration per state.
Q: What if my screen resolution is different from 1920x1080?โ
A: Create patterns at your target resolution. Brobot will capture at the same resolution. The key is consistency between pattern creation and execution.
Q: How can I verify which resolution my patterns are?โ
A: Check the image properties or use Brobot's debug mode to log pattern dimensions:
brobot.screenshot.save-snapshots=true
brobot.console.actions.enabled=true
Summaryโ
For optimal pattern matching:
- Use OS native screenshot tools - Windows Snipping Tool, macOS Screenshot, or Linux Screenshot tools
- Keep default Brobot configuration - JAVACV_FFMPEG for runtime capture
- Save patterns as PNG - Avoid compression artifacts
- Organize patterns by state - Easier maintenance
Key insight: Clean, artifact-free patterns from native OS tools match better during runtime than patterns captured with the same tool used for runtime capture. This counterintuitive result occurs because noise and artifacts compound when present in both pattern and runtime images.