processFrame static method
Preprocesses a raw image frame and returns a comprehensive PreprocessingResult.
Implementation
static PreprocessingResult processFrame(
Uint8List rawBytes,
int width,
int height, {
double blurThreshold = 80.0,
bool applyBinarization = false,
}) {
final gray = toGrayscale(rawBytes, width, height);
final blurScore = computeBlurScore(gray, width, height);
final lumaData = computeLuminosityAndContrast(gray, width, height);
final luma = lumaData['luminosity'] ?? 0.5;
final contrast = lumaData['contrast'] ?? 0.5;
final isBlurry = blurScore < blurThreshold;
final isLowLight = luma < 0.22;
final isOverexposed = luma > 0.88;
Uint8List finalBytes = gray;
if (applyBinarization) {
finalBytes = sauvolaBinarize(gray, width, height);
}
return PreprocessingResult(
bytes: finalBytes,
width: width,
height: height,
blurScore: blurScore,
isBlurry: isBlurry,
luminosity: luma,
contrastScore: contrast,
isLowLight: isLowLight,
isOverexposed: isOverexposed,
);
}