Firebase 如何使用ML套件云文本识别器识别颤振?

Firebase 如何使用ML套件云文本识别器识别颤振?,firebase,dart,flutter,google-cloud-vision,firebase-mlkit,Firebase,Dart,Flutter,Google Cloud Vision,Firebase Mlkit,我在我的项目中使用“firebase\u ml\u vision”包来进行OCR。我可以很好地阅读拉丁语,但是我想读汉字。我知道在设备上和基于云的文本识别器版本都有。但是,我无法找到如何在我的应用程序中“启用”基于云的版本。我已经在Firebase中激活了基于云的API,如下图所示: 我目前使用的代码是: void _initializeVision() async{ final File imageFile = File(imagePath); final FirebaseVisionIma

我在我的项目中使用“firebase\u ml\u vision”包来进行OCR。我可以很好地阅读拉丁语,但是我想读汉字。我知道在设备上和基于云的文本识别器版本都有。但是,我无法找到如何在我的应用程序中“启用”基于云的版本。我已经在Firebase中激活了基于云的API,如下图所示:

我目前使用的代码是:

void _initializeVision() async{
final File imageFile = File(imagePath);
final FirebaseVisionImage visionImage = FirebaseVisionImage.fromFile(imageFile);


final TextRecognizer textRecognizer = FirebaseVision.instance.textRecognizer();
final VisionText visionText = await textRecognizer.processImage(visionImage);



for(TextBlock blocks in visionText.blocks){
  for(TextLine line in blocks.lines){
    print(line.text);
  }
}}

结果:

I/flutter (10432): FamilyMart Collection
I/flutter (10432): 10
I/flutter (10432): Pocket facial tissue
I/flutter (10432): Without fluorescent virgin fber from wood puip
I/flutter (10432): pampers your skin

有人能给我解释一下如何使用cloud文本识别器进行颤振吗?

有同样的问题,不要认为cloud OCR目前可以与ML软件包一起使用。我设法通过一个POST请求使它工作。 以下是您需要的一切:


注意:您应该使用
FirebaseVision.instance.CloudTextRecognitizer().processImage(fbi)
,但它产生的结果仍然远不如建议的答案准确
// Upload Image to Firebase and get
// 1. DownloadUrl or 
// 2. StorageBucket or
//
// 3. Convert Image to base64 with
// String base64Image = base64Encode(File(imagePath).readAsBytesSync());
// (does not work for me, if you use this way make sure your `body` is correct)

String body = """{
  'requests': [
    {
      'image': {
        'source': {
          'imageUri': '$downloadUrl'
        }
      },
      'features': [
        {
          'type': 'DOCUMENT_TEXT_DETECTION'
        }
      ]
    }
  ]
}""";

http.Response res = await http
  .post(
    "https://vision.googleapis.com/v1/images:annotate?key=$API_KEY",
    body: body
  );

print("${res.body}");