PHP code example of doododo / ocr
1. Go to this page and download the library: Download doododo/ocr library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
doododo / ocr example snippets
$ocr = new \Doododo\OCR\OCR([
'app_id' => 'xxxx',
'app_key' => 'xxxx'
]);
$ocr->idCard($image); // 注意绝对路径或URL
# 1. 创建 `ocr.php` 文件
return [
'app_id' => 'xxxx',
'app_key' => 'xxxx'
];
# 2. 修改 `AppServiceProvider.php` 的 `boot()` 添加
use Doododo\OCR\OCR;
$this->app->singleton(OCR::class, function () {
return new OCR(config('ocr'));
});
$this->app->alias(OCR::class, 'ocr');
# 3. 使用
$ocr = app('ocr');
$ocr->idCard($image); // 注意绝对路径或URL
// 身份证正面
$ocr->idCard($image);
// 身份证反面
$ocr->idCard($image, 1);
// 行驶证
$ocr->driverLicense($image);
// 驾驶证
$ocr->driverLicense($image, 1);
$ocr->generic('https://cdn.ai.qq.com/aiplat/static/ai-demo/large/o-1.jpg');
$ocr->businessLicense('https://cdn.ai.qq.com/aiplat/static/ai-demo/large/odemo-pic-5.jpg');
$ocr->businessLicense('https://cdn.ai.qq.com/aiplat/static/ai-demo/large/odemo-pic-5.jpg');
$ocr->handwrite('https://cdn.ai.qq.com/ai/assets/ai-demo/large/hd-5-lg.jpg');
$ocr->plateLicense('https://cdn.ai.qq.com/ai/assets/ai-demo/large/plate-1-lg.jpg')
$ocr->businessCard('https://cdn.ai.qq.com/aiplat/static/ai-demo/large/odemo-pic-2.jpg');