estey / evernote-ocr
此包已被弃用,不再维护。未建议替代包。
使用Evernote API对图像文件执行文本识别(OCR)。
v0.2.0
2014-10-23 15:52 UTC
Requires
- php: >=5.4
- evernote/evernote-cloud-sdk-php: dev-master
Requires (Dev)
- illuminate/filesystem: 4.2.*
- league/flysystem: 0.5.*
- mockery/mockery: ~0.9
- phpunit/php-code-coverage: ~2.0
- phpunit/phpunit: ~4.0
- satooshi/php-coveralls: dev-master
- squizlabs/php_codesniffer: ~1.5
Suggests
- illuminate/filesystem: Illuminate Filesystem.
- league/flysystem: Flysystem.
This package is not auto-updated.
Last update: 2023-11-20 22:45:17 UTC
README
这是一个非官方库,用于将Evernote API作为图像文本识别的手段。请注意,仅为了应用程序的OCR目的使用Evernote API违反了API许可协议。
安装
通过编辑项目中的composer.json
文件以要求estey/evernote-ocr
来通过Composer
安装此包。
{ "require": { "estey/evernote-ocr": "0.2.*" } }
然后,更新Composer
composer update
要获取新的Evernote Dev Token,请登录您的帐户并使用此链接:https://www.evernote.com/api/DeveloperToken.action
使用方法
use Estey\EvernoteOCR\Client; $client = new Client('YOUR DEV TOKEN'); $response = $client->recognize('path/to/image.jpg'); print_r($response);
recognize方法将返回一个包含TextBlock
对象的数组,每个对象都有一个文本识别选项的数组。每个Text
对象包含识别的文本和一个0-100的置信度分数。每个TextBlock
包含文本被找到的X和Y坐标以及文本块的像素宽度和高度。
Array
(
[0] => Estey\EvernoteOCR\TextBlock Object
(
[x] => 51
[y] => 82
[width] => 307
[height] => 35
[options] => Array
(
[0] => Estey\EvernoteOCR\Text Object
(
[text] => SEPTEMBER
[confidence] => 91
)
)
)
[1] => Estey\EvernoteOCR\TextBlock Object
(
[x] => 370
[y] => 87
[width] => 128
[height] => 30
[options] => Array
(
[0] => Estey\EvernoteOCR\Text Object
(
[text] => 2014
[confidence] => 77
)
[1] => Estey\EvernoteOCR\Text Object
(
[text] => 201 a
[confidence] => 35
)
)
)
)
Laravel文件系统适配器
如果您使用的是Laravel,有一个服务提供者可用。打开app/config/app.php
,并将服务提供者添加到providers
数组中。您还需要将您的Evernote Dev Token添加到.env
文件中,键设置为EVERNOTE_DEV_TOKEN
。
'Estey\EvernoteOCR\Providers\Illuminate\EvernoteOCRServiceProvider'
使用方式如下
$client = App::make('evernote_ocr', ['path/to/image.jpg']); $response = $client->recognize(); print_r($response);
Flysystem适配器
Evernote OCR包自带了一个内置适配器,支持Flysystem文件系统库。
use Estey\EvernoteOCR\Client; use Estey\EvernoteOCR\FileAdapters\FlysystemFileAdapter; use League\Flysystem\Filesystem; use League\Flysystem\Adapter\Local as Adapter; $filesystem = new Filesystem( new Adapter(__DIR__ . '/path/to/root/') ); $client = new Client('YOUR DEV TOKEN'); $file = new FlysystemFileAdapter('path/to/image.jpg', $filesystem); $response = $client->recognize($file); print_r($response);
许可
MIT许可(MIT)。请参阅许可文件以获取更多信息。