analyse static method
CaptureAdvice
analyse({
- required double brightness,
- CustomFace? signal,
- required bool faceChecksAvailable,
- bool? fullyInsideFrame,
Implementation
static CaptureAdvice analyse({
required double brightness,
CustomFace? signal,
required bool faceChecksAvailable,
bool? fullyInsideFrame,
}) {
if (brightness < minBrightness) {
return const CaptureAdvice(
CaptureIssue.tooDark,
'Too dark to see you. Move somewhere brighter or turn a light on.',
canCapture: false,
);
}
if (brightness > maxBrightness) {
return const CaptureAdvice(
CaptureIssue.tooBright,
'Too bright. Try turning away from the light behind you.',
canCapture: false,
);
}
if (!faceChecksAvailable || signal == null) {
return const CaptureAdvice(
CaptureIssue.none,
'Line your face up with the circle.',
canCapture: true,
);
}
if (fullyInsideFrame == false) {
return const CaptureAdvice(
CaptureIssue.outsideFrame,
'Move your whole face inside the circle.',
canCapture: false,
);
}
final double yaw = signal.headEulerAngleY ?? 0.0;
if (yaw.abs() > maxYaw) {
return const CaptureAdvice(
CaptureIssue.turned,
'Look straight at the camera.',
canCapture: false,
);
}
return const CaptureAdvice(
CaptureIssue.none,
'Hold still.',
canCapture: true,
);
}