flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

[firebase_ml_vision] FirebaseVisionImage.fromFile() doesn't work for .HEIC format images

Open Furtim opened this issue 7 years ago • 4 comments

Describe the bug Calling FirebaseVisionImage.fromFile(image) on a file retrieved by the ImagePicker gallery stored in .HEIC format results in no usable text being identified when calling the final VisionText visionText = await textRecognizer.processImage(visionImage), call.

If you perform the same steps having first converted the file the jpeg format and saving it in the gallery, the text is correctly detected.

To Reproduce Sample snippet: onPressed: () async { var image = await ImagePicker.pickImage(source: ImageSource.gallery); if (image == null) { return; } final FirebaseVisionImage visionImage = FirebaseVisionImage.fromFile(image); final TextRecognizer textRecognizer = FirebaseVision.instance.textRecognizer(); final VisionText visionText = await textRecognizer.processImage( visionImage, ); print('Vision Text ${visionText.text}');

Will work if you select a native jpg, will fail to detect text if you select a native HEIC format image.

Expected behavior I would expect the FirebaseVisionImage.fromFile() and subsequent text recognition to give the same result regardless of whether the original image is in .HEIC or JPG format given this is the detault for IOS now. Additional context

Furtim avatar Sep 14 '19 17:09 Furtim

Is there a workaround to convert HEIC to JPG via flutter/dart?

jherrmann avatar Mar 25 '20 12:03 jherrmann

As a workaround until .heic is supported you can change the settings of your iPhone. When you change the format to Most Compatible it should save new images as .jpeg

Path to change the format: 'Settings>Camera>Formats>Most Compatible'

eddiesTime avatar May 13 '20 12:05 eddiesTime

got the same issue on iOS when image is taken by camera. Works fine with the same image saved to the device folder

UPDATE: could be solved using this pub flutter_exif_rotation

XbIK avatar Jan 14 '21 08:01 XbIK

Hey, :wave:, the firebase_ml_vision package is now discontinued since its APIs have been deprecated and removed from the Android & iOS Firebase SDKs.

I'd recommend switching to the alternatives now;

  • for on-device vision APIs; switch to Google's standalone ML Kit library via google_ml_kit
  • for cloud vision APIs; the recommended approach now is to use Firebase Authentication and Functions, which gives you a managed, serverless gateway to the Google Cloud Vision APIs. For an example Functions project see the vision-annotate-images sample project. You'd deploy this project for example and then call the cloud function from your app with your image data to get the annotation result.

Apologies for any inconvenience here and best of luck switching over the the new APIs. firebase_ml_custom is not affected by this deprecation.

Thanks

Salakar avatar May 10 '21 14:05 Salakar