faceapidetectionweb 1.0.0+1
faceapidetectionweb: ^1.0.0+1 copied to clipboard
A Flutter package for face detection and expression analysis using JavaScript interop, providing camera controls and photo capture capabilities for web applications. this
faceapidetectionweb #
A new Flutter project.
Getting Started #
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
For help getting started with Flutter development, view the online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.
API Documentation #
JSBridge Class #
The JSBridge
class is used to interact with JavaScript for camera and face detection functionalities.
Methods
-
initialize({required Function(bool) onCameraStateChanged, required Function(String) onCameraError, required Function(String, String) onPhotoTaken, required Function(bool, List<Map<String, dynamic>>) onFaceDetectionStatus})
- Initializes the JSBridge with the provided callback functions.
- Parameters:
onCameraStateChanged
: Callback when the camera state changes.onCameraError
: Callback when there is a camera error.onPhotoTaken
: Callback when a photo is taken.onFaceDetectionStatus
: Callback when the face detection status changes.
-
Future<bool> openCamera()
- Opens the camera.
- Returns: A
Future
that resolves totrue
if the camera was opened successfully, otherwisefalse
.
-
void closeCamera()
- Closes the camera.
-
void takePhoto()
- Takes a photo using the camera.
CounterWidget Class #
The CounterWidget
class is a stateful widget that uses the JSBridge
to interact with the camera and perform face detection.
State Variables
_isCameraOpen
: A boolean indicating whether the camera is open._lastPhotoTaken
: A string containing the URL of the last photo taken._lastPhotoWithBox
: A string containing the URL of the last photo taken with a bounding box._faceDetected
: A boolean indicating whether a face was detected._expressions
: A list of maps containing the detected expressions.
Methods
_toggleCamera()
- Toggles the camera state between open and closed.
UI Components #
- A container that serves as a placeholder for the camera view.
- Text widgets to display the face detection status and expressions.
- Buttons to open/close the camera and take a photo.
- Image widgets to display the last photo taken and the last photo with a bounding box.