In this recipe, you will add the face detection feature to the existing project: the model will predict whether the faces in the picture are smiling and have their eyes open. Follow these steps:
- In the ml.dart file, add a new async method, called faceRecognition. The method takes File as a parameter, and returns a future of type String:
Future<String> faceRecognition(File image) async {} - At the top of the faceRecognition method, declare three variables: String, FirebaseVision, and FirebaseVisionImage:
String result = '';
final FirebaseVision vision = FirebaseVision.instance;
final FirebaseVisionImage visionImage = FirebaseVisionImage.fromFile(image);
- Also declare a FaceDetector enabling Classification, Landmark, and Tracking:
FaceDetector detector = vision.faceDetector(const FaceDetectorOptions(
enableClassification: true,
enableLandmarks: true,
enableTracking: true,
mode...