使用 PHP 从图像中读取文本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2024238/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 04:42:56  来源:igfitidea点击:

Read text from an image with PHP

phpimage

提问by Adnan

I would like to try to read some of text from an image with PHP.

我想尝试使用 PHP 从图像中读取一些文本。

So if I have an image like this:

所以如果我有这样的图像:

enter image description here

在此处输入图片说明

How can I extract the text "Some text" into a string.

如何将文本“Some text”提取为字符串。

All help and suggestions are appreciated.

感谢所有帮助和建议。

回答by David Pfeffer

The process you are looking for is called Optical Character Recognition.

您正在寻找的过程称为光学字符识别。

http://en.wikipedia.org/wiki/Optical_character_recognition

http://en.wikipedia.org/wiki/Optical_character_recognition

There is a package available, called phpOCR, that does exactly what you need.

有一个名为 phpOCR 的包可用,它完全符合您的需要。

http://sourceforge.net/projects/phpocr/

http://sourceforge.net/projects/phpocr/

回答by Sebastian Viereck

phpOCR ist not the best choice, I would recommend TesseractOCR for PHP "A wrapper to work with TesseractOCR inside your PHP scripts." https://github.com/thiagoalessio/tesseract-ocr-for-php

phpOCR 不是最好的选择,我会推荐 TesseractOCR for PHP “在 PHP 脚本中使用 TesseractOCR 的包装器。” https://github.com/thiagoalessio/tesseract-ocr-for-php

回答by Jimmy Shelter

That's called OCR. (See http://en.wikipedia.org/wiki/Optical_character_recognition).

这就是所谓的OCR。(参见http://en.wikipedia.org/wiki/Optical_character_recognition)。

It's not a trival task (that's why captcha's work as good as they do).

这不是一项微不足道的任务(这就是为什么验证码的效果和它们一样好)。

You'd be better of googling 'OCR PHP' if you want to find solutions.

如果您想找到解决方案,最好使用谷歌搜索“OCR PHP”。