第一步可定要獲取百度的三個(gè)東西 要到百度AI網(wǎng)站(http://ai.baidu.com/)去注冊(cè) 然后獲得
-const APP_ID = '請(qǐng)?zhí)顚懩愕腶ppid';-const API_KEY = '請(qǐng)?zhí)顚懩愕腁PI_KEY';-const SECRET_KEY = '請(qǐng)?zhí)顚懩愕腟ECRET_KEY';
第二步下載SDK
https://github.com/jankinsun/New/tree/master/OCR/character_recognition
或者使用官方的 http://ai.baidu.com/sdk 下載
第三步 然后就直接運(yùn)行demo 的文件 DemoAipOcr.php
里面的圖片都可以
我這里自己試了一下
返回的數(shù)據(jù)是
轉(zhuǎn)json后
{ "log_id": 3394339616, "words_result_num": 3, "classify_result": { "lottery": "unknown" }, "words_result": [ { "words": "友誼" }, { "words": "以相同的價(jià)值觀選擇朋友," }, { "words": "無(wú)論對(duì)方富有或貧窮。" } ]}感覺還是不錯(cuò)的
如果報(bào)錯(cuò)了 : Fatal error: Call to undefined function getimagesizefromstring()
因?yàn)槌绦蜻\(yùn)行的過(guò)程中會(huì)調(diào)用getimagesizefromstring 函數(shù) — Get the size of an image from a string 把圖像轉(zhuǎn)化成字符 所以要求PHP版本(PHP 5 >= 5.4.0, PHP 7)
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持VeVb武林網(wǎng)。
新聞熱點(diǎn)
疑難解答
圖片精選