thinkphp + 腾讯云名片识别

腾讯云:

搜索:OCR 或者 名片识别 

依赖环境

  • PHP 5.6.33 版本及以上。
  • 获取安全凭证。安全凭证包含 SecretId 及 SecretKey 两部分。SecretId 用于标识 API 调用者的身份,SecretKey 用于加密签名字符串和服务器端验证签名字符串的密钥。

在项目下执行:

//最好使用 Git 打开
composer require tencentcloud/tencentcloud-sdk-php

建议使用新版的:OCR-名片识别(V2)新版名片识别

public function getOCR(){
    $img = input("imageSrc");
    if($img){
        try {
            $cred = new Credential("SecretId", "SecretKey");
            $httpProfile = new HttpProfile();
            $httpProfile->setEndpoint("ocr.tencentcloudapi.com");
            $clientProfile = new ClientProfile();
            $clientProfile->setHttpProfile($httpProfile);
            $client = new OcrClient($cred, "ap-guangzhou", $clientProfile);
            $req = new BusinessCardOCRRequest();
            $params = array(
                "ImageBase64" => $img
                //"ImageUrl" => "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=967415216,1615300876&fm=26&gp=0.jpg"
            );
            $req->fromJsonString(json_encode($params));
            $resp = $client->BusinessCardOCR($req);
            //print_r($resp->toJsonString());
            return json($resp);
        }
        catch(TencentCloudSDKException $e) {
            return $e;
        }
    }
}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

逸曦穆泽

您的鼓励是我的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值