Package io.github.jspinak.brobot.action.internal.capture


package io.github.jspinak.brobot.action.internal.capture
Internal utilities for screen capture and region definition operations.

This package contains internal support classes that handle the low-level details of capturing screen regions, defining boundaries, and managing capture-related operations. These utilities are used by the public capture and region definition actions to perform their core functionality.

Key Components

  • invalid reference
    io.github.jspinak.brobot.action.internal.capture.RegionDefinitionHelper
    - Common utilities for region definition operations
  • DefinedBorders - Manages border definitions and constraints for regions
  • AnchorRegion - Calculates regions based on anchor points and relationships

Region Definition Support

Coordinate Calculations

  • Convert between different coordinate systems
  • Calculate bounding boxes from multiple points
  • Apply offsets and margins to regions
  • Ensure regions stay within screen bounds

Anchor-based Calculations

  • Find regions between anchor points
  • Calculate relative positions from anchors
  • Expand regions to include all anchors
  • Define exclusion zones around anchors

Border Management

  • Define fixed borders for regions
  • Calculate dynamic borders based on content
  • Apply border constraints during region operations
  • Handle border intersections and overlaps

Capture Utilities

  • Screen Capture - Low-level screen grabbing operations
  • Region Validation - Ensure regions are valid and within bounds
  • Coordinate Transformation - Handle different coordinate spaces
  • Image Cropping - Extract specific regions from captures

Common Operations

Region Expansion/Contraction


 // Internal utility usage (not public API)
 Region original = new Region(100, 100, 200, 150);
 Region expanded = DefineHelper.expandRegion(original, 10); // 10 pixel margin
 Region contracted = DefineHelper.contractRegion(original, 5); // 5 pixel inset
 

Anchor Calculations


 // Calculate region between anchors
 List<Match> anchors = Arrays.asList(topLeft, bottomRight);
 Region between = AnchorRegion.calculateBetween(anchors);

 // Calculate region including all anchors with margin
 Region including = AnchorRegion.calculateIncluding(anchors, 20);
 

Border Constraints


 // Apply border constraints to region
 DefinedBorders borders = new DefinedBorders(10, 10, 50, 50); // margins
 Region constrained = borders.constrainRegion(originalRegion);
 

Integration with Public API

These internal utilities support the public capture actions:

  • DefineRegion uses these for basic region operations
  • DefineInsideAnchors uses anchor calculations
  • DefineWithMatch uses match-based region calculations
  • Highlight uses capture utilities for visual feedback

Performance Optimizations

  • Cached screen dimensions to avoid repeated queries
  • Efficient boundary checking algorithms
  • Minimal object allocation in calculation paths
  • Reusable capture buffers where possible

Error Handling

  • Graceful handling of invalid regions
  • Automatic clamping to screen boundaries
  • Clear error messages for debugging
  • Fallback strategies for edge cases
See Also:
  • Classes
    Class
    Description
    Handles the adjustment of region boundaries based on anchor points from matched elements.
    Tracks which borders of a region have been defined during the region definition process.
    V2 version that provides reusable helper methods for the various Define actions.