combineEstimate method

FinderPattern combineEstimate(
  1. double i,
  2. double j,
  3. double newModuleSize
)

Combines this object's current estimate of a finder pattern position and module size with a new estimate. It returns a new FinderPattern containing a weighted average based on count.

Implementation

FinderPattern combineEstimate(double i, double j, double newModuleSize) {
  final combinedCount = _count + 1;
  final combinedX = (_count * x + j) / combinedCount;
  final combinedY = (_count * y + i) / combinedCount;
  final combinedModuleSize =
      (_count * _estimatedModuleSize + newModuleSize) / combinedCount;
  return FinderPattern(
    combinedX,
    combinedY,
    combinedModuleSize,
    combinedCount,
  );
}