Google iOS return 上的 ML KIt 文本识别始终为空结果

Google MLKIt TextRecognition on iOS return always empty result

我正在使用 react-native, react-native-vision-camera (with frameProcessor) and mlkit 执行设备文本识别。

我的代码在 Android 上运行,但我在 iOS.

上总是得到 empty 结果

这是我的 Objective C 实现:

static inline id scanOCR(Frame* frame, NSArray* args) {
  MLKTextRecognizer *textRecognizer = [MLKTextRecognizer textRecognizer];
  MLKVisionImage *image = [[MLKVisionImage alloc] initWithBuffer:frame.buffer];
  image.orientation = frame.orientation;
  
  NSError *error;
  MLKText *result = [textRecognizer resultsInImage:image error:&error];
  if (error != nil || result == nil) {
    NSLog(@"%@", error); // <- This is NEVER called
  } else {
    NSLog(@"text: %@", result.text); // <- this is always empty
    NSLog(@"blocks lenght: %lu", (unsigned long)result.blocks.count); // <- this is always 0
  }
  return @{@"text": result.text};  
}

项目正确编译,没有错误,但results.text始终为空,即使相机正在取景文本也是如此。

我认为 MLKit 已正确安装。这是我的 Podfile

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '11.0'

target 'com.digitalbore.papertag' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  pod 'GoogleMLKit/TextRecognition','2.2.0'

  target 'com.digitalbore.papertagTests' do
    inherit! :complete
    # Pods for testing
    pod 'react-native-splash-screen', :path => '../node_modules/react-native-splash-screen'

    pod 'react-native-receive-sharing-intent', :path => '../node_modules/react-native-receive-sharing-intent'

  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

通过将 iPhone iOS 版本更新到最新版本解决。

为了进一步了解这里的情况,您能否确认您在设备上使用 Google 机器学习套件 quickstart vision app 没有得到任何文本结果?