导航:首页 > 源码编译 > ai技术获客系统源码

ai技术获客系统源码

发布时间:2023-03-04 22:52:16

❶ 有没有微信小程序调用百度ai车辆识别接口的程序源码,很简单的就可以

class BaiDuAiBaseController extends BaseController
{
private $appid;
private $appKey;
private $secretKey;

public function __construct(){
$this->appid= config('api..appid');
$this->appKey = config('api..apikey');
$this->secretKey = config('api..secretkey');
}

//网络ai接口--文字识别--车牌号识别
public function getCarNumber($_imgurl,$_img=''){
$_token = $this->getToken();
$_url = 'https://aip.bce.com/rest/2.0/ocr/v1/license_plate?access_token='.$_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('_token')){
$_access_token = cache('_token');
}else{
$_url = 'https://aip.bce.com/oauth/2.0/token?grant_type=client_credentials&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('_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
},

❷ 如果想优化ai模型部署,哪些源码值得一读

想优化ai模型部署,以下3个源码值得一读。
1、普通应用程序或网络应用场景中的源码值得一读。
2、Paddle模型源码。
3、AI模型的快速端云部署源码。

❸ 百度AI人脸注册源码详解

1、起点 AppConfig.client.addUser(image, imageType, groupId, userId, options) 调用人脸注册api,从addUser进入

2、那就要看一下_request请求是怎么发送的,点进去看

3、至此调用基本结束,接下来看里面用到的几个方法:

阅读全文

与ai技术获客系统源码相关的资料

热点内容
解压玩具是水宝宝 浏览:815
压缩机保护怎么解决 浏览:942
单片机简易电子时钟 浏览:400
pdf影印版 浏览:689
单片机的中断技术 浏览:616
表格加密才能打开 浏览:39
多态可以提高编译可靠性吗 浏览:599
拼好魔方的app怎么下载 浏览:503
江苏金税盘测试服务器地址是什么 浏览:607
螺杆式压缩冷凝机组 浏览:299
p在单片机里什么意思 浏览:25
linuxwireshark使用教程 浏览:656
手机访问阿里服务器地址 浏览:678
程序员可以干什么 浏览:71
绩效考核权重分配算法 浏览:524
android应用logo 浏览:898
光遇安卓服墓土商店什么时候开 浏览:566
月收益翻倍的源码 浏览:639
asop源码放在哪里 浏览:991
电脑服务器密码怎么找 浏览:576