Package io.github.jspinak.brobot.action.basic.find.motion


package io.github.jspinak.brobot.action.basic.find.motion
Motion detection and dynamic element tracking.

This package provides sophisticated motion detection capabilities for identifying and tracking moving elements in the GUI. It can distinguish between static and dynamic pixels, track moving objects, and identify regions of motion activity.

Core Capabilities

  • Motion Detection - Identify pixels and regions that change over time
  • Dynamic Tracking - Follow moving elements across frames
  • Static vs Dynamic Classification - Distinguish fixed UI elements from animated ones
  • Motion Visualization - Visual representation of detected motion for debugging

Key Classes

  • FindMotion - Main motion detection action that coordinates the motion analysis process
  • FindDynamicPixelMatches - Identifies pixels that change between frames (moving elements)
  • FindFixedPixelMatches - Identifies pixels that remain constant (static UI elements)
  • FindRegionsOfMotion - Groups motion pixels into coherent regions representing moving objects
  • invalid reference
    io.github.jspinak.brobot.action.basic.find.motion.IllustrateMotion
    - Creates visual representations of detected motion for analysis and debugging

Motion Detection Process

  1. Capture multiple frames over a time period
  2. Compare pixels across frames to identify changes
  3. Classify pixels as static or dynamic based on change patterns
  4. Group dynamic pixels into motion regions
  5. Track motion regions across frames
  6. Return motion matches with trajectory information

Use Cases

  • Tracking animated UI elements (loading spinners, progress bars)
  • Detecting pop-ups or notifications that slide into view
  • Following game characters or moving objects
  • Identifying areas of screen activity
  • Waiting for animations to complete
  • Distinguishing between static background and moving foreground

Example Usage


 // Detect motion in a specific region
 FindMotion findMotion = new FindMotion(...);

 ActionConfig options = new ActionConfig.Builder()
     .setAction(ActionType.FIND)
     .setFind(Find.MOTION)
     .setMaxWait(5.0)  // Observe for 5 seconds
     .build();

 ObjectCollection searchRegion = new ObjectCollection.Builder()
     .withRegions(Region.SCREEN)  // Or specific region
     .build();

 ActionResult result = findMotion.perform(new ActionResult(), searchRegion);

 // Visualize detected motion
 IllustrateMotion illustrate = new IllustrateMotion(...);
 ActionResult visualization = illustrate.perform(result, searchRegion);

 // Access motion regions
 for (Match motionMatch : result.getMatches()) {
     System.out.println("Motion detected at: " + motionMatch.getRegion());
 }
 

Performance Considerations

  • Motion detection requires capturing multiple frames
  • Larger regions require more processing time
  • Adjust frame rate and duration based on expected motion speed
  • Use region constraints to focus on specific areas
See Also:
  • invalid reference
    io.github.jspinak.brobot.imageUtils.MotionDetector
  • invalid reference
    io.github.jspinak.brobot.action.basic.wait.OnChange