dtueufe82643 2016-12-15 10:34
浏览 170

PHP - 执行文件路径错误(Tesseract)

I have ran tesseract in the commandline and got results back ok but now i am using the same command with PHP exec it will not work.

The command is:

"C:\Program Files (x86)\Tesseract-OCR\tesseract.exe" "C:\xampp\htdocs\Atoms Projects\Tesseract\text.jpeg" "C:\xampp\htdocs\Atoms Projects\Tesseract\Out.txt"

I tried this code:

exec("C:\Program Files (x86)\Tesseract-OCR\tesseract.exe" "C:\xampp\htdocs\Atoms Projects\Tesseract\text.jpeg" "C:\xampp\htdocs\Atoms Projects\Tesseract\Out.txt");
print_r($msg);

How can i make the command work correctly?

Also is there any way to send in multiple lines? to split into vars like:

$exe = "C:\Program Files (x86)\Tesseract-OCR\tesseract.exe";
$img = "C:\xampp\htdocs\User Projects\Tesseract\text.jpeg";
$txt = "C:\xampp\htdocs\User Projects\Tesseract\Out.txt";

This is also not working:

$exe = "C:\Program Files (x86)\Tesseract-OCR\tesseract.exe";
$img = "C:\xampp\htdocs\Atoms Projects\Tesseract\text.jpeg";
$txt = "C:\xampp\htdocs\Atoms Projects\Tesseract\Out";
$output = exec("\"$exe\" \"$img\" \"$txt\" "); 
print_r($output);

I am using XAMPP on Windows OS.

  • 写回答

1条回答 默认 最新

  • dongleibeng5602 2016-12-15 11:38
    关注

    I just found the solution which was to change all \ characters to / in the 3 paths like this:

    $exe = "C:/Program Files (x86)/Tesseract-OCR/tesseract.exe";
    $img = "C:/xampp/htdocs/Atoms Projects/Tesseract/text.jpeg";
    $txt = "C:/xampp/htdocs/Atoms Projects/Tesseract/Out";
    $output = exec("\"$exe\" \"$img\" \"$txt\" "); 
    print_r($output);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计