关于php:PHP-Composer拓展包华为云OCR文字识别

5次阅读

共计 1171 个字符,预计需要花费 3 分钟才能阅读完成。

介绍

本我的项目集成了华为云 OCR 文字辨认业务,反对 ThinkPHP5.0、ThinkPHP5.1 和 ThinkPHP6.0,由宁波晟嘉网络科技有限公司保护。

装置教程

应用 composer require singka/singka-hwocr 命令行装置即可。

应用示例(基于 ThinkPHP6.0)

<?php
// +----------------------------------------------------------------------
// | 胜家云 [SingKa Cloud]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.singka.net All rights reserved.
// +----------------------------------------------------------------------
// | 宁波晟嘉网络科技有限公司
// +----------------------------------------------------------------------
// | Author: ShyComet <shycomet@qq.com>
// +----------------------------------------------------------------------
namespace app\home\controller;

use SingKa\HwOcr\HwOcr;

class Index extends Base
{
    /**
    * OCR 文字辨认示例
    *
    * @appKey       华为云 appKey
    * @appSecret    华为云 appSecret
    * @regionName   资源所在区域
    */
    public function ocrDemo()
    {$config['appKey'] = 'YXMWB********PKZY';
        $config['appSecret'] = 'wC2*em*7*********EDP';
        $config['regionName'] = 'cn-north-4';
        // 别离传入配置、OCR 辨认类型、图片地址或 Base64 码和其余参数
        $result = HwOcr::AkskRequest($config, 'business-license', 'http://tuoxing.shop/ocr/data/business-license-demo.jpg', []);
        return json(json_decode($result, true));
    }
  
}

其余阐明

相干资料请查阅:
华为云文字辨认、SDK 简介、API 概览

更多内容请拜访作者集体网站 尘墨成

正文完
 0