Apparence-io / CamerAwesome

πŸ“Έ Embedding a camera experience within your own app shouldn't be that hard. A flutter plugin to integrate awesome Android / iOS camera experience.
https://ApparenceKit.dev
MIT License
947 stars 234 forks source link

Improve drawing of image analysis results #186

Closed apalala-dev closed 1 year ago

apalala-dev commented 1 year ago

Description

This PR intends to make the example using face detection more accurate. It should give an idea on how to position elements on top of specific points of the preview.

It needs to be tested on iOS @dim-apparence

Checklist

Before creating any Pull Request, confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).

Breaking Change

CameraAwesomeBuilder and AwesomeCameraPreview now include a PreviewDecoratorBuilder:

typedef PreviewDecoratorBuilder = Widget Function(
  CameraState state,
  PreviewSize previewSize,

  /// [previewRect] might be clipped (especially in Ratio 1:1)
  Rect previewRect,
);

It is especially useful for drawing elements on top of the preview. With previewRect, one can get exactly the rect of the camera preview and its previewSize (not clipped) for positioning a point calculated through the image analysis. In the example, it is used to draw outline of a face when one is detected.

I included this builder in the awesome builder as well as in the custom since both can use image analysis (and that's where it will be mainly used).