FaceDetectionCameraOverlay class
A composite widget that overlays face-detection and (optional) segmentation results on top of a live camera preview.
Assembles up to four layers inside an AspectRatio sized Stack:
- A full-screen virtual background (BackgroundImagePainter) when virtualBackground is provided and showVirtualBackground is true.
- The caller-provided cameraPreview.
- A virtual-background composite (VirtualBackgroundOverlayPainter) that cuts the subject out of the camera and places them on virtualBackground.
- Or, when showSegmentation is enabled without a virtual background, a LiveSegmentationPainter tint.
- A CameraDetectionPainter drawing bounding boxes, mesh, landmarks etc. for the provided faces (only when imageSize is non-null).
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- FaceDetectionCameraOverlay
Constructors
-
FaceDetectionCameraOverlay({Key? key, required Widget cameraPreview, required double cameraAspectRatio, required double displayAspectRatio, required bool mirrorHorizontally, required int sensorOrientation, required Orientation deviceOrientation, required bool isFrontCamera, required FaceDetectionMode detectionMode, required List<
Face> faces, Size? imageSize, SegmentationMask? segmentationMask, Image? virtualBackground, bool showSegmentation = false, bool showVirtualBackground = false, Color segmentationColor = const Color(0x8800FF00), bool segmentationShowAllClasses = false, List<Color> segmentationClassColors = kSegmentationClassColors, bool showPoseAndScores = false, bool showClassification = false}) -
const
Properties
- cameraAspectRatio → double
-
Aspect ratio of the raw camera frames (width / height). Used by the
detection painter to map face coordinates.
final
- cameraPreview → Widget
-
The camera preview widget (typically a
CameraPreview).final - detectionMode → FaceDetectionMode
-
Detection mode that produced the faces (controls which overlays the
painter considers valid).
final
- deviceOrientation → Orientation
-
Current device orientation (portrait/landscape).
final
- displayAspectRatio → double
-
Aspect ratio used for the display AspectRatio box. Often the inverse
of cameraAspectRatio when the device is in portrait.
final
-
faces
→ List<
Face> -
Detected faces to draw via CameraDetectionPainter.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- imageSize → Size?
-
Size of the image used for detection (post-rotation). The detection
painter is skipped when null.
final
- isFrontCamera → bool
-
Whether the active camera is the front-facing camera.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- mirrorHorizontally → bool
-
Whether the detection and segmentation overlays should be mirrored
horizontally (usually true for front cameras on Android).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
segmentationClassColors
→ List<
Color> -
Per-class colors for multiclass segmentation. Defaults to
kSegmentationClassColors.
final
- segmentationColor → Color
-
Tint color used by the standalone segmentation overlay. Ignored for
multiclass rendering (see segmentationShowAllClasses).
final
- segmentationMask → SegmentationMask?
-
Segmentation mask output from the detector, or null when segmentation
is not active.
final
- segmentationShowAllClasses → bool
-
When true, render every class in segmentationClassColors instead of a
single-color tint. Use for multiclass segmentation models.
final
- sensorOrientation → int
-
Sensor mount orientation in degrees (0/90/180/270).
final
- showClassification → bool
-
Whether to append smile / eye-open probabilities to the per-face info
card (full mode only). Opt-in; independent of showPoseAndScores.
final
- showPoseAndScores → bool
-
When true, the detection painter draws a per-face info card with
detection/mesh confidence and head pose Euler angles.
final
- showSegmentation → bool
-
Whether to render the standalone segmentation tint overlay. Ignored when
showVirtualBackground is true.
final
- showVirtualBackground → bool
-
Whether to replace the background with virtualBackground, cutting the
subject out using segmentationMask.
final
- virtualBackground → Image?
-
Optional virtual-background image painted behind the subject.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited