AutoZoomController class

Smooth camera auto-zoom controller inspired by Dynamsoft Barcode Reader SDK.

v3.0 upgrade: Replaces instant zoom jumps with smooth animated zoom using ease-out interpolation, settling detection, velocity limiting, and hysteresis band to prevent zoom oscillation.

Features:

  • Smooth ease-out zoom animation (configurable duration)
  • Zoom settling detection (N stable frames before declaring complete)
  • Maximum zoom velocity limiting (prevents jarring jumps)
  • Hysteresis band (±5% dead zone to prevent oscillation)
  • Distance estimation from barcode module size

Constructors

AutoZoomController({double minZoom = 1.0, double maxZoom = 5.0, double targetAreaFraction = 0.25, double lerpFactor = 0.15, double maxZoomVelocity = 0.4, double hysteresisBand = 0.05, int settlingFrameCount = 5})

Properties

currentZoom double
Current zoom factor level.
no setter
hashCode int
The hash code for this object.
no setterinherited
hysteresisBand double
Hysteresis band: don't adjust zoom for area changes within this range.
final
isSettled bool
Whether zoom has settled (stable for N frames).
no setter
lastZoomChangeTime DateTime?
Time when zoom level was last adjusted.
no setter
lerpFactor double
final
maxZoom double
final
maxZoomVelocity double
Maximum zoom change per update (velocity limiter).
final
minZoom double
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
settlingFrameCount int
Number of stable frames required before zoom is considered settled.
final
stableFrames int
Number of consecutive stable frames.
no setter
targetAreaFraction double
final
targetZoom double
Target zoom level being animated towards.
no setter

Methods

estimateZoomFromModuleSize({required double moduleWidthPixels, double idealModuleWidth = 3.0}) double
Estimates optimal zoom level from barcode module size.
evaluateTargetZoom({required Rect targetBoundingBox, required Rect roiScanWindow, required Size frameSize}) double
Calculates desired target zoom level based on target bounding box area relative to scan window ROI.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reset() → void
Resets zoom back to minimum 1.0.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited