Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Q:System.InvalidOperationException:在Xamarin中调用Init first(OCR TESSERACT)错误_Xamarin - Fatal编程技术网

Q:System.InvalidOperationException:在Xamarin中调用Init first(OCR TESSERACT)错误

Q:System.InvalidOperationException:在Xamarin中调用Init first(OCR TESSERACT)错误,xamarin,Xamarin,如果(tesserResult)始终为false,执行tesseract OCR必须为true,有人可以帮助我吗 if (!_tesseractApi.Initialized) await _tesseractApi.Init("eng"); var photo = await TakePic(); if (photo != null) { // When setting an ImageSource using a stream, // the

如果(tesserResult)
始终为false,执行tesseract OCR必须为true,有人可以帮助我吗

if (!_tesseractApi.Initialized)
    await _tesseractApi.Init("eng"); 

  var photo = await TakePic();
  if (photo != null)
  {
      // When setting an ImageSource using a stream, 
      // the stream gets closed, so to avoid that I backed up
      // the image into a byte array with the following code:
      var imageBytes = new byte[photo.Source.Length];
      photo.Source.Position = 0;
      photo.Source.Read(imageBytes, 0, (int)photo.Source.Length);
      photo.Source.Position = 0;

      var tessResult = await _tesseractApi.SetImage(imageBytes);

      if (tessResult) 
      {
        _takenImage.Source = ImageSource.FromStream(() => photo.Source);
        _recognizedTextLabel.Text = _tesseractApi.Text;
      }
  }
}

将Tesseract train文件(在您的示例中为英语Tesseract train文件)放入您的资产文件夹中。

尝试将Tesseract数据导入项目:

听起来您没有成功初始化Tesseractyah,但我已经初始化了它,但我不知道它为什么会失败。你知道怎么修吗@Jasonnope,我建议询问Tesseract开发人员,或者查看他们的示例应用程序(如果他们有)ohhh好的,谢谢@Jasonnope您是否检查了日志中的Init步骤错误消息?网上有很多帖子都是关于在初始化过程中与缺少许可证有关的错误。尽管你的答案可能是100%正确,但如果链接被移动、更改、合并到另一个链接或主站点消失,它也可能会变得100%无用…:-(因此,请给出您的答案,并将链接中的相关步骤复制到您的答案中,从而保证您的答案在本网站的整个生命周期中都是100%;-)您可以始终将链接保留在答案的底部,作为材料的来源。。。