導航:首頁 > 源碼編譯 > 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技術獲客系統源碼相關的資料

熱點內容
linuxwireshark使用教程 瀏覽:650
手機訪問阿里伺服器地址 瀏覽:678
程序員可以干什麼 瀏覽:70
績效考核權重分配演算法 瀏覽:524
android應用logo 瀏覽:898
光遇安卓服墓土商店什麼時候開 瀏覽:566
月收益翻倍的源碼 瀏覽:638
asop源碼放在哪裡 瀏覽:989
電腦伺服器密碼怎麼找 瀏覽:574
jdp轉換pdf 瀏覽:749
把pdf導入iphone 瀏覽:508
米哈游租賃的雲伺服器是哪個 瀏覽:524
android直接打電話 瀏覽:1016
ubuntu停止命令 瀏覽:285
cnc攻絲編程 瀏覽:869
換個手機號碼app怎麼注冊 瀏覽:320
怎麼下載小猴口算app 瀏覽:116
輕鏈app的貨怎麼樣 瀏覽:626
電腦里的u盤如何加密 瀏覽:372
我的世界全部版本伺服器下載地址 瀏覽:50