首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google MLKIt TextRecognition on iOS返回总是空的结果

Google MLKIt TextRecognition on iOS返回总是空的结果
EN

Stack Overflow用户
提问于 2022-02-04 13:55:20
回答 2查看 473关注 0票数 0

我正在使用反应本土化反应-本机-摄像机 (与frameProcessor一起)和迈尔吉特来执行设备文本识别。

我的代码在Android上工作,但是我总是在上获得空的结果。

以下是我的目标C:

代码语言:javascript
复制
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的安装是恰当的。这是我的个人档案

代码语言:javascript
复制
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
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-02-07 14:15:24

通过将iPhone iOS版本更新到最后一个版本来解决问题。

票数 0
EN

Stack Overflow用户

发布于 2022-02-07 16:19:14

为了进一步了解这里的情况,您能验证一下您的设备上的Google quickstart视觉应用程序没有收到任何文本结果吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70987534

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档