Class MovingObjectSelector

java.lang.Object
io.github.jspinak.brobot.analysis.motion.MovingObjectSelector

@Component public class MovingObjectSelector extends Object
Identifies moving objects by analyzing motion patterns across three consecutive scenes. This class implements an algorithm that distinguishes true moving objects from background changes by tracking consistent motion trajectories.

The algorithm works by:

  • Finding overlapping regions between scene transitions
  • Identifying opposite-direction movements that indicate object motion
  • Verifying consistent distances to confirm the same object is moving

A moving object is identified when:

  1. A match region overlaps between two scene transitions
  2. There's a match in the opposite direction (>150° difference)
  3. The distances are consistent, indicating the same object

This approach effectively filters out camera movements and background changes, focusing on objects that move independently within the scene.

See Also:
  • Constructor Details

    • MovingObjectSelector

      public MovingObjectSelector(DistanceCalculator distance)
      Constructs a MovingObjectSelector instance with distance calculation utility.
      Parameters:
      distance - utility for calculating distances and angles between matches
  • Method Details

    • select

      public List<List<Match>> select(List<Match> matchList1, List<Match> matchList2, int maxDistance)
      Selects moving objects by analyzing motion patterns across three scenes. The algorithm identifies objects that move in opposite directions between scene transitions, which indicates independent object motion rather than camera movement or background changes.

      The returned list contains three sublists:

      • Index 0: Matches from scene 1 (starting positions)
      • Index 1: Overlapping matches in scene 2 (intermediate positions)
      • Index 2: Matches from scene 3 (final positions)
      Parameters:
      matchList1 - matches representing changes between scenes 1 and 2
      matchList2 - matches representing changes between scenes 2 and 3
      maxDistance - maximum allowed distance for related matches
      Returns:
      list of three lists containing matches for each scene's moving objects