douyi7055
2018-01-17 10:19
浏览 107
已采纳

如何在wamp服务器上使用Tesseract PHP包装器

I used composer to install this Tesseract PHP wrapper : https://github.com/thiagoalessio/tesseract-ocr-for-php by typing the following command line directly from my php project folder located at C:/wamp/www/project_folder:

$ composer require thiagoalessio/tesseract_ocr

I created a php file called 'new' in the same folder where i try to use tesseract by typing :

use thiagoalessio\TesseractOCR\TesseractOCR;
echo (new TesseractOCR('text.png'))
->run();

I get the following error :

Fatal error: Class 'thiagoalessio\TesseractOCR\TesseractOCR' not found in C:\wamp\www\project_folder ew.php on line 4

Here's the content of my project folder :

   vendor(a folder)
   composer.json 
   composer.lock
   new.php 
   test.png 

I have wampserver version 2.5 I have already installed tesseract (version 4) at C:program files I included the following code to my php file in order to set the path but still encoutering the error.

$path = getenv('PATH');
putenv("PATH=$path:C:\Program Files\Tesseract_OCR");

图片转代码服务由CSDN问答提供 功能建议

我使用composer来安装这个Tesseract PHP包装器: https://github.com/thiagoalessio/tesseract -ocr-for-php 直接从位于 C:/ wamp / www / project_folder 的php项目文件夹中键入以下命令行: $ composer require thiagoalessio / tesseract_ocr

我在同一文件夹中创建了一个名为'new'的php文件,我尝试使用tesseract键入:

 使用thiagoalessio \ TesseractOCR \ TesseractOCR; 
echo(new TesseractOCR('text.png'))
-> run(); 
  <  / pre> 
 
 

我收到以下错误:

致命错误:在C中未找到类'thiagoalessio \ TesseractOCR \ TesseractOCR': 第4行\ wamp \ www \ project_folder ew.php

以下是我的项目文件夹的内容:

 < 代码>供应商(文件夹)
 composer.json 
 composer.lock 
 new.php 
 test.png 
   
 
 

我有wampserver ve rsion 2.5 我已经在C:程序文件中安装了tesseract(版本4) 我将以下代码包含在我的php文件中,以便设置路径但仍然包含错误。

  $ path = getenv('PATH'); 
putenv(“PATH = $ path:C:\ Program Files \ Tesseract_OCR”); 
  <  / pre> 
 
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongqiu8375 2018-01-17 11:01
    已采纳

    Does new.php contain the include for autoload.php? You most probably have to add require_once __DIR__ . '/vendor/autoload.php'; at the top of that file

    已采纳该答案
    打赏 评论
  • douji5329 2018-01-18 11:00

    I fixed the problem by first using a newer version of PHP as Nico Haase suggested, and second putting my php file on the same path as the tesseract executable.

    打赏 评论

相关推荐 更多相似问题