Skip to main content
Version: Latest

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.

๐Ÿ† Optimal Tools for Pattern Creationโ€‹

These tools provide the best pattern matching during runtime automation:

  • 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:
    1. Press Win + Shift + S to open Snipping Tool
    2. Select the area you want to capture
    3. Save as PNG in your project's images/ directory

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
  • 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โ€‹

  1. 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
  2. For testing patterns: Use Brobot Pattern Capture Tool
  3. If you have existing patterns: Test their match rates and consider recapturing with native tools

Step 2: Capture Patternsโ€‹

  1. Ensure your display is at the target resolution
  2. Capture UI elements with your chosen tool
  3. Save as PNG files (avoid JPEG to prevent compression artifacts)
  4. 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%:

  1. Check Resolution Mismatch

    • Pattern: 1920x1080, Capture: 1536x864 โ†’ ~77% similarity
    • Solution: Use matching capture provider or enable scaling
  2. Check DPI Settings

    # In your application.properties
    brobot.dpi.disable=true # For physical resolution
  3. 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โ€‹

  1. Lower similarity threshold if needed:

    brobot.action.similarity=0.85  # Default is 0.95
  2. Check if pattern is unique enough:

    • Avoid capturing too small areas
    • Include distinctive features
    • Avoid areas with changing content

Resolution Compatibility Tableโ€‹

Pattern Creation ToolBest Brobot ProviderRuntime Match RateRecommendation
Windows Snipping ToolJAVACV_FFMPEG95-100%RECOMMENDED
macOS ScreenshotJAVACV_FFMPEG95-100%RECOMMENDED
Linux ScreenshotJAVACV_FFMPEG95-100%RECOMMENDED
Brobot FFmpeg ToolJAVACV_FFMPEG70-80%Testing only
SikuliX IDEJAVACV_FFMPEG70-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:
    1. Run Brobot on Windows directly (use PowerShell or Command Prompt)
    2. Use mock mode for testing in WSL (brobot.mock=true)
    3. Create patterns on Windows, test on Windows

Migration Guideโ€‹

From Existing Patternsโ€‹

If you have patterns created with other tools:

  1. Identify pattern resolution:

    # Check image properties
    file pattern.png
    # Or use image viewer to check dimensions
  2. Adjust Brobot configuration:

    • 1920x1080 patterns โ†’ Use default configuration
    • 1536x864 patterns โ†’ Switch to SIKULIX provider
    • Other resolutions โ†’ May need custom scaling
  3. 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:

  1. Use OS native screenshot tools - Windows Snipping Tool, macOS Screenshot, or Linux Screenshot tools
  2. Keep default Brobot configuration - JAVACV_FFMPEG for runtime capture
  3. Save patterns as PNG - Avoid compression artifacts
  4. 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.