Screen Capture Quick Reference
Switch Capture Providerโ
Method 1: Properties File โ (Recommended)โ
# 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โ
| Provider | Dependencies | Resolution | Performance | Setup | Default |
|---|---|---|---|---|---|
| JAVACV_FFMPEG | JavaCV (included) | Physical | Good | None | โ Yes |
| SikuliX | SikuliX (included) | Java 21: Logical / Java 8: Physical | Good | None | No |
| Robot | None | Configurable (Physical or Logical) | Fast | Configure scaling | No |
| FFMPEG | External FFmpeg | Physical | Good | Install FFmpeg | No |
*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โ
| Issue | Solution |
|---|---|
| Wrong resolution (1536x864) | Enable Robot scaling: brobot.capture.robot.scale-to-physical=true |
| Provider not available | Switch to ROBOT: brobot.capture.provider=ROBOT |
| Intermittent failures | Enable retry: brobot.capture.auto-retry=true |
| Need to debug | Enable 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.
Related Documentationโ
Core Capture Documentationโ
- DPI and Resolution Guide - Comprehensive guide to handling DPI scaling and resolution issues
- Capture Methods Comparison - Detailed performance study comparing all capture providers
- Modular Capture System Guide - Complete examples with class context and imports
Configurationโ
- Configuration Properties Reference - Complete reference for all Brobot configuration properties
- Configuration Note - Configuration best practices
Testing & Deploymentโ
- CI/CD Testing Guide - Testing Brobot applications in CI/CD pipelines
- Mock Mode Guide - Testing without GUI using mock mode
Technical Deep Divesโ
Troubleshootingโ
- Action Config Troubleshooting - Debugging action chains and configuration issues