php百度图像识别api(百度图像识别api调用)
华为云服务器特价优惠火热进行中! 2核2G2兆仅需 38 元;4核4G3兆仅需 79 元。购买时间越长越优惠!更多配置及优惠价格请咨询客服。
合作流程: |
今天给各位分享php百度图像识别api的知识,其中也会对百度图像识别api调用进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
微信号:cloud7591如需了解更多,欢迎添加客服微信咨询。
复制微信号
本文目录一览:
- 1、有没有微信小程序调用百度ai车辆识别接口的程序源码,很简单的就可以?
- 2、php识别二维码
- 3、如何在百度浏览器中使用百度识图功能?
- 4、php怎么做图片识别
- 5、php 如何把图片上的文字提取出来
有没有微信小程序调用百度ai车辆识别接口的程序源码,很简单的就可以?
class BaiDuAiBaseController extends BaseController
{
private $appid;
private $appKey;
private $secretKey;
public function __construct(){
$this-appid= config('api.baidu.appid');
$this-appKey = config('api.baidu.apikey');
$this-secretKey = config('api.baidu.secretkey');
}
//百度ai接口--文字识别--车牌号识别
public function getCarNumber($_imgurl,$_img=''){
$_token = $this-getToken();
$_url = ''.$_token;
if($_img){
$_data = [
'image'=$_img//图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式
];
}else{
$_data = [
'url'=request()-domain().'/'.$_imgurl
];
}
$_res = json_decode(httpGet($_url,$_data),true);
//TODO 此处只返回false没有终止,是因为程序执行流程需要,后期可能要改
if(isset($_res['error_msg'])) return false;
return $_res['words_result']['number'];
}
//获取token
private function getToken(){
if(cache('baidu_token')){
$_access_token = cache('baidu_token');
}else{
$_url = ';client_id='.$this-appKey.'client_secret='.$this-secretKey;
$res = json_decode(httpGet($_url),true);
if(isset($res['error']))TApiException($res['error_description']);//终止程序并抛出异常
$_access_token = $res['access_token'];
$_expires_in = $res['expires_in'];
cache('baidu_token',$_access_token,($_expires_in-1000));//我喜欢少存1000秒,没有为什么,问就是癖好
}
return $_access_token;
}
}
这是ThinkPhp5.1后端封装的百度AI接口类,getToken()获取凭证,getCarNumber()请求$_url 返回识别结果,这个是车牌号码识别,车型识别等其他接口大部分都一样,就换个请求地址$_url就行
//接口:
public function getImgCarNum(){
$_number = (new BaiDuAiBaseController())-getCarNumber(false,request()-param('img'));
return self::myShow('申请成功',['carNum'=$_number]);
}
小程序端正常request请求上面的接口就行,下面是微信小程序拍照识别功能
//拍照
goImgSearch(){
uni.chooseImage({
count:1,
sizeType: ['compressed'],//original 原图,compressed 压缩图
sourceType: ['album','camera'],//camera 相机 album相册
success:(r)={
console.log(r)
//执行识别车牌号码
this.img = r.tempFilePaths[0]
this.urlTobase64(r.tempFilePaths[0])
}
})
},
//识别车牌号码
urlTobase64(url){
uni.showLoading({
title:'拼命识别车牌中..'
})
//#ifdef MP-WEIXIN
uni.getFileSystemManager().readFile({
filePath: url, //选择图片时返回的路径
encoding: "base64",//这个是很重要的
success: res = { //成功的回调
//返回base64格式
let base64 = 'data:image/jpeg;base64,' + res.data
//发送请求,识别车牌号码
this.$H.post('/getImgCarNum',{
img:base64 //图片数据
},{
token:true //必须登录
}).then((res)={
console.log(res.carNum)
if(!res.carNum){
uni.hideLoading()
return uni.showModal({
title:'识别失败',
content:'没能识别到车牌号码,请拍张清晰的图片再试哦,谢谢',
showCancel:false
})
}
uni.showToast({
title:'识别车牌成功',
icon:'none'
})
this.searchUser = res.carNum
this.userCarNum = res.carNum
uni.hideLoading()
}).catch((e)={
uni.hideLoading()
return uni.showModal({
title:'识别失败',
content:'没能识别到车牌号码,请拍张清晰的图片再试哦,谢谢',
showCancel:false
})
})
},
fail:(e)={
console.log(e)
}
})
//#endif
},
php识别二维码
二维码只是一个图像,php是可以读取图像识别出内容的。
其它语言都可以,凭什么PHP不可以,都它妈是语言
网上搜索有很多实现的,去github上搜索php qrcode

如何在百度浏览器中使用百度识图功能?
您可以在网页里的图片上,右击选择“百度识图”即可轻松搜找到原图,还能智能识别图中人物。更多详细内容请点击百度官方论坛:
php怎么做图片识别
个人建议:楼主使用php进行图片识别,不如使用ocr文字识别技术来进行图片识别,这样更方便,请看下面的方法:
首先,在电脑上安装ocr文字识别软件(迅捷ocr文字识别软件)。
接着,运行ocr,选择上面的‘极速识别’功能。
然后,点击左上角的‘添加文件’,不需要识别的图片添加进去。
最后,点击操作下面的‘开始识别’按钮。
希望上方的方法可以帮助到你。
php 如何把图片上的文字提取出来
提取图片上文字,必须用到识别功能,即OCR。
自己写很难,因为要有识别库。
建议使用开源的Tesserac识别库。
目前也有很多成熟的OCR的API,可以看下。
php百度图像识别api的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于百度图像识别api调用、php百度图像识别api的信息别忘了在本站进行查找喔。
