Skip to main content
Version: Latest

Screen Capture Quick Reference

Switch Capture Providerโ€‹

# application.properties
# Default is already JAVACV_FFMPEG, but you can change it:
brobot.capture.provider=JAVACV_FFMPEG # Default (or SIKULIX, ROBOT, FFMPEG, AUTO)

# DPI manual scaling (default is 1.0, or use 'auto' for auto-detection):
brobot.dpi.resize-factor=1.0

Method 2: Command Lineโ€‹

java -Dbrobot.capture.provider=FFMPEG -jar myapp.jar

Method 3: Runtime Codeโ€‹

@Autowired
private CaptureConfiguration config;

config.useRobot(); // Switch to Robot
config.useFFmpeg(); // Switch to FFmpeg (JavaCV)
config.useSikuliX(); // Switch to SikuliX

Provider Comparisonโ€‹

ProviderDependenciesResolutionPerformanceSetupDefault
JAVACV_FFMPEGJavaCV (included)PhysicalGoodNoneโœ… Yes
SikuliXSikuliX (included)Java 21: Logical / Java 8: PhysicalGoodNoneNo
RobotNoneConfigurable (Physical or Logical)FastConfigure scalingNo
FFMPEGExternal FFmpegPhysicalGoodInstall FFmpegNo

*Robot captures at logical resolution by default, physical when scale-to-physical=true SikuliX resolution depends on Java version (21: logical, 8: physical) JAVACV_FFMPEG uses bundled JavaCV library for native capture

Essential Propertiesโ€‹

# Choose provider (JAVACV_FFMPEG is default, or SIKULIX, ROBOT, FFMPEG, AUTO)
brobot.capture.provider=JAVACV_FFMPEG

# DPI scaling (default is 1.0 - no scaling, or use 'auto' for auto-detection)
brobot.dpi.resize-factor=1.0

# Robot: Enable physical resolution scaling
brobot.capture.robot.scale-to-physical=true
brobot.capture.robot.expected-physical-width=1920
brobot.capture.robot.expected-physical-height=1080

# FFmpeg: Configure capture (uses JavaCV)
brobot.capture.ffmpeg.timeout=5
brobot.capture.ffmpeg.format=png

# General: Enable retry and fallback
brobot.capture.auto-retry=true
brobot.capture.retry-count=3
brobot.capture.fallback-enabled=true

Usage Examplesโ€‹

Prerequisites: All examples assume a Spring Boot application with Brobot dependencies. Add these imports to your class:

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import io.github.jspinak.brobot.capture.*;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.IOException;

For complete runnable examples with full class context, see the Modular Capture System Guide.

Basic Captureโ€‹

@Autowired
private UnifiedCaptureService capture;

// Same code works with ANY provider!
BufferedImage screen = capture.captureScreen();
BufferedImage region = capture.captureRegion(new Rectangle(100, 100, 400, 300));

Check Configurationโ€‹

@Autowired
private CaptureConfiguration config;

// Current provider
String provider = config.getCurrentProvider();

// Physical resolution?
boolean physical = config.isCapturingPhysicalResolution();

// Print full report
config.printConfigurationReport();

Common Scenariosโ€‹

Scenario 1: Development Machineโ€‹

# Use default JAVACV_FFMPEG for reliable physical resolution capture
# (No configuration needed - these are defaults)
brobot.capture.provider=JAVACV_FFMPEG
brobot.dpi.resize-factor=1.0

Scenario 2: CI/CD Pipelineโ€‹

# Auto-select best available
brobot.capture.provider=AUTO
brobot.capture.fallback-enabled=true

Scenario 3: Production Serverโ€‹

# Use JAVACV_FFMPEG for reliability (no external dependencies)
brobot.capture.provider=JAVACV_FFMPEG
brobot.capture.retry-count=5

Scenario 4: Windows with DPI Scalingโ€‹

# Robot with scaling compensation
brobot.capture.provider=ROBOT
brobot.capture.robot.scale-to-physical=true
brobot.capture.robot.expected-physical-width=1920

Troubleshootingโ€‹

IssueSolution
Wrong resolution (1536x864)Enable Robot scaling: brobot.capture.robot.scale-to-physical=true
Provider not availableSwitch to ROBOT: brobot.capture.provider=ROBOT
Intermittent failuresEnable retry: brobot.capture.auto-retry=true
Need to debugEnable logging: brobot.capture.enable-logging=true

Decision Treeโ€‹

Which provider should I use?

โ”Œโ”€ Need reliable physical resolution capture?
โ”‚ โ””โ”€ Yes โ†’ JAVACV_FFMPEG (default, bundled JavaCV)
โ”‚ โ””โ”€ No โ†“
โ”‚
โ”œโ”€ Need fastest performance?
โ”‚ โ””โ”€ Yes โ†’ Robot (with manual DPI configuration)
โ”‚ โ””โ”€ No โ†“
โ”‚
โ”œโ”€ Using Java 8 and need backward compatibility?
โ”‚ โ””โ”€ Yes โ†’ SikuliX (physical on Java 8)
โ”‚ โ””โ”€ No โ†“
โ”‚
โ”œโ”€ Have external FFmpeg installed?
โ”‚ โ””โ”€ Yes โ†’ FFMPEG (external FFmpeg binary)
โ”‚ โ””โ”€ No โ†“
โ”‚
โ””โ”€ Unsure? โ†’ Stay with JAVACV_FFMPEG (default)

Key Pointsโ€‹

โœ… No code changes needed when switching providers โœ… JAVACV_FFMPEG bundled (JavaCV included in Brobot) โœ… Physical resolution by default for accurate pattern matching โœ… Properties control everything โœ… Automatic fallback for robustness

Default Setupโ€‹

No configuration needed! Brobot defaults to:

# These are already set in brobot-defaults.properties:
brobot.capture.provider=JAVACV_FFMPEG
brobot.dpi.resize-factor=1.0

Your application automatically uses JAVACV_FFMPEG with physical resolution capture for optimal pattern matching accuracy.


Core Capture Documentationโ€‹

Configurationโ€‹

Testing & Deploymentโ€‹

Technical Deep Divesโ€‹

Troubleshootingโ€‹