By following these steps, you will add an image labeling feature to the existing app:
- In the ml.dart file, add a new async method and call it labelImage. The method takes File as a parameter and returns a string:
Future<String> labelImage(File image) async {}
- At the top of the labelImage method, declare four variables: String, FirebaseVision, FirebaseVisionImage, and ImageLabeler, as shown:
String result = '';
final FirebaseVision vision = FirebaseVision.instance;
final FirebaseVisionImage visionImage = FirebaseVisionImage.fromFile(image);
ImageLabeler labeler = vision.imageLabeler();
- After the declarations, insert a try/catch: in the try block, call the ImageLabeler processImage method to retrieve a list of ImageLabel objects. For each label in the list, add its text and confidenceLevel into the result string. In the catch block, just print the error that was returned:
try {
List...