身份證OCR識別

騰訊雲文檔

https://ai.qq.com/doc/ocridcardocr.shtml

調用騰訊 AI 接口的 Java 客戶端 Taip 

TAIP 是調用騰訊 AI 接口的 Java 客戶端,爲調用騰訊 AI 功能的開發人員提供了一系列的交互方法。

目前已經接入

【face人臉識別】

  • 人臉檢測與分析、多人臉檢測、人臉對比、跨年齡人臉識別、五官定位、人臉識別、人臉驗證、個體創建、刪除個體、增加人臉、刪除人臉、設置信息、獲取信息、獲取組列表、獲取個體列表、獲取人臉列表、獲取人臉信息接口調用服務

【ptu圖片特效】

  • 人臉美妝、人臉變妝、圖片濾鏡(天天P圖)、圖片濾鏡(AI Lab)、人臉融合、大頭貼、顏齡檢測接口調用服務

自然語言處理TAipNlp】

  • ( 分詞、詞性標註、專有名詞識別、同義詞識別、意圖成分識別、情感分析、基礎閒聊、文本翻譯(AI Lab)、文本翻譯(翻譯君)、圖片翻譯 、語音翻譯、語種識別 )接口調用服務

智能鑑黃、暴恐圖片識別TAipVision】

  • ( 智能鑑黃、暴恐圖片識別)接口調用服務

語音合成、識別TAipSpeech】

  • (語音識別-echo版、語音識別-流式版(AI Lab)、語音識別-流式版(WeChat AI)、長語音識別、語音合成(AI Lab)、語音合成(優圖))接口調用服務

文字識別TAipOcr】

  • (身份證識別、名片識別、行駛證駕駛證識別、營業執照識別、銀行卡識別、通用OCR識別)接口調用服務

圖像識別TAipImageClassify】

  • (物體場景識別、圖片標籤識別、花草/車輛識別、看圖說話、模糊圖片檢測、美食圖片識別)接口調用服務

Java JDK 1.7+

  • 項目結構介紹

cn.xsshome.taip
       ├── base                                //基類
       ├── http                                //Http通信相關類
       ├── error                                //SDK錯誤類
       ├── imageclassify
       │       └── TAipImageClassify           //TAipImageClassify類
       ├── sign                                //簽名公用類
       ├── ocr
       │       └── TAipOcr                      //TAipOcr類
       ├── speech
       │       └── TAipSpeech                   //TAipSpeech類
       ├── face
       │       └── TAipFace                   //TAipFace類
       ├── ptu
       │       └── TAipPtu                   //TAipPtu類
       ├── nlp
       │       └── TAipNlp                   //TAipNlp類
       ├── vision
       │       └── TAipVision                   //TAipVision類
       └── util                                //工具類
  • 使用 maven 引入即可(最新版本4.2.2)

  • OCR 示例代碼

TAipOcr 是調用騰訊 AI 中 OCR 的 Java 客戶端,爲調用騰訊 AI 中 OCR 功能的開發人員提供了一系列的交互方法。

用戶可以參考如下代碼新建一個 TAipOcr,初始化完成後建議單例使用:

public class Sample {
    //設置APPID/APP_KEY
    public static final String APP_ID = "你的 App ID";
    public static final String APP_KEY = "你的 Api Key";

    public static void main(String[] args) {
        // 初始化一個TAipOcr
       TAipOcr aipOcr = new TAipOcr(APP_ID,APP_KEY);
        // 調用接口
        String result = aipOcr.idcardOcr("./idcard.jpg", 0);//身份證正面(圖片)識別
        String result = aipOcr.idcardOcr("./idcard2.jpg", 1);//身份證反面(國徽)識別
        String result = aipOcr.bcOcr("./juli2.jpg");//名片識別
        String result = aipOcr.driverlicenseOcr("./driver.jpg",0);//行駛證OCR識別
        String result = aipOcr.driverlicenseOcr("./driver2.jpg",1);//駕駛證OCR識別
        String result = aipOcr.bizlicenseOcr("./biz.jpg");//營業執照OCR識別
        String result = aipOcr.creditcardOcr("./bank2.jpg");//銀行卡OCR識別
        String result = aipOcr.generalOcr("./biz.jpg");//通用OCR識別
    }
}
  • ASR、TTS 示例代碼

新建TAipSpeech TAipSpeech是調用騰訊AI中語音識別、合成的Java客戶端,爲調用騰訊AI中語音識別、合成功能的開發人員提供了一系列的交互方法。

用戶可以參考如下代碼新建一個TAipSpeech,初始化完成後建議單例使用:

public class Sample {
    //設置APPID/APP_KEY
    public static final String APP_ID = "你的 App ID";
    public static final String APP_KEY = "你的 Api Key";

    public static void main(String[] args) {
        // 初始化一個TAipSpeech
        TAipSpeech aipSpeech = new TAipSpeech(APP_ID, APP_KEY);
        // 調用接口
        String filePath ="./VOICE1513237078.pcm";//本地文件路徑
        byte[] audio = FileUtil.readFileByBytes(filePath);//獲取文件的byte數據
        String result = aipSpeech.asrEcho(filePath, 1);//語音識別-echo版
        String result = aipSpeech.asrLab(1, 16000, 0, 1024, 1, audio);//語音識別-流式版(AI Lab)
        String result = aipSpeech.asrWx(filePath, 1, 16000, 16, 0, 1024, 1, 1);//語音識別-流式版(WeChat AI)
        String text = "小帥封裝代碼";
        String result = aipSpeech.TtaSynthesis(text);//語音合成(優圖)     默認參數
        String result = aipSpeech.TtaSynthesis(text,2,1);//語音合成(優圖)     全部參數
        String result = aipSpeech.TtsSynthesis(text, 1, 3);//語音合成(AI Lab) 默認參數
        String result = aipSpeech.TtsSynthesis(text,1,3,0,100,0,58);//語音合成(AI Lab) 全部參數
        String result = aipSpeech.asrLong("G:/16.pcm", 1, "http://yourwebsitename.com/methodname");//長語音識別
        System.out.println(result);
    }
}

 

  • 圖像識別 示例代碼

TAipImageClassify是調用騰訊AI中圖像識別的Java客戶端,爲調用騰訊AI中圖像識別功能的開發人員提供了一系列的交互方法。

用戶可以參考如下代碼新建一個 TAipImageClassify,初始化完成後建議單例使用:

public class Sample {
    //設置APPID/APP_KEY
    public static final String APP_ID = "你的 App ID";
    public static final String APP_KEY = "你的 Api Key";
    public static void main(String[] args) throws Exception {
        // 初始化一個TAipImageClassify
        TAipImageClassify aipImageClassify = new TAipImageClassify(APP_ID, APP_KEY);
        String filePath = "G:/x5.jpg";//本地文件路徑
        byte[] image = FileUtil.readFileByBytes(filePath);//獲取文件的byte數據
        String result = aipImageClassify.visionScener(image, 1, 5);//場景識別
        String result = aipImageClassify.visionObjectr(image, 1, 5);//物體識別
        String result = aipImageClassify.imageTag(image);//圖像標籤識別
        String result = aipImageClassify.visionImgidentify(image, 1);//車輛識別
        String result = aipImageClassify.visionImgidentify(image, 2);//花草識別
        String result = aipImageClassify.flowersAndPlant(image);//花草識別
        String result = aipImageClassify.vehicle(image);//車輛識別
        String result = aipImageClassify.visionImgtotext(image,RandomNonceStrUtil.getRandomString());//看圖說話
        String result = aipImageClassify.imageFuzzy(image);//模糊圖片檢測    
        String result = aipImageClassify.imageFood(image);//美食圖片識別    
        System.out.println(result);
        
    }
}
  • 人臉識別 示例代碼

TAipFace是調用騰訊AI中人臉識別的Java客戶端,爲調用騰訊AI中人臉識別功能的開發人員提供了一系列的交互方法。

用戶可以參考如下代碼新建一個 TAipFace,初始化完成後建議單例使用:

public class Sample{
 //設置APPID/APP_KEY
    public static final String APP_ID = "你的 App ID";
    public static final String APP_KEY = "你的 Api Key";
    public static void main(String[] args) throws Exception {
         // 初始化一個TAipPtu
        TAipFace aipFace = new TAipFace(APP_ID, APP_KEY);
        String filePath = "G:/body2.jpg";
        String filePathA = "G:/dc.jpg";
        String filePathB = "G:/dcg.jpg";
        /**********人臉識別**********/
        String result = aipFace.detect(filePath);//人臉檢測與分析
        String result = aipFace.detectMulti(filePath);    //多人臉檢測
        String result = aipFace.faceCompare(filePathA, filePathB);    //人臉對比     
        String result = aipFace.detectCrossage(filePathA, filePathB);//跨年齡人臉識別
        String result = aipFace.faceShape(filePathA);//五官定位     
        String result = aipFace.faceIdentify(filePath, "group01", 9);//人臉識別
        String result = aipFace.faceVerify(filePath, "20180511");//人臉驗證
        /**********個體管理**********/
        String result = aipFace.faceNewperson(filePath,"group20180511","201805110001","測試");//個體創建
        String result = aipFace.faceDelperson("201805110001");//刪除個體
        /*增加人臉 圖片二進制List*/
        List bytes = new ArrayList();
        byte [] faceA = FileUtil.readFileByBytes(filePathA);
        byte [] faceB = FileUtil.readFileByBytes(filePathB);
        bytes.add(faceA);
        bytes.add(faceB);
        String result = aipFace.faceAddfaceByte(bytes,"201805110001","測試增加人臉");
        /*增加人臉 圖片本地路徑List*/
        List filePaths = new ArrayList();
        filePaths.add(filePathA);
        filePaths.add(filePathB);
        String result = aipFace.faceAddfaceByFilePath(filePaths,"201805110001","測試增加人臉");//增加人臉
        String result = aipFace.faceDelFace("201805110001", "2573556034542000336");//刪除人臉
        String result = aipFace.faceSetInfo("201805110001", "小帥測試","測試接口");//設置信息
        String result = aipFace.faceGetInfo("201805110001");//獲取信息
        /**********信息查詢**********/
        String result = aipFace.getGroupIds();//獲取組列表
        String result = aipFace.getPersonIds("group20180511");//獲取個體列表
        String result = aipFace.getFaceIds("201805110001");//獲取人臉列表
        String result = aipFace.getFaceInfo("2573564663139686751");//獲取人臉信息     
        System.out.println(result);
    }
}
  • 圖片特效 示例代碼

TAipPtu是調用騰訊AI中圖片特效的Java客戶端,爲調用騰訊AI中圖片特效功能的開發人員提供了一系列的交互方法。

用戶可以參考如下代碼新建一個 TAipPtu,初始化完成後建議單例使用:

public class Sample{
     //設置APPID/APP_KEY
    public static final String APP_ID = "你的 App ID";
    public static final String APP_KEY = "你的 Api Key";
    public static void main(String[] args) throws Exception {
        // 初始化一個TAipPtu
        TAipPtu aipPtu = new TAipPtu(APP_ID, APP_KEY);
        String imagePath = "G:/test2.jpg";
        String result = aipPtu.faceCosmetic(imagePath, 23);//人臉美妝     
        String result = aipPtu.faceDecoration(imagePath, 8);//人臉變妝     
        String result = aipPtu.imgFilter(imagePath, 20);//濾鏡 天天P圖     
        String result = aipPtu.visionImgfilter(imagePath, 32, String.valueOf(new Date().getTime()));//濾鏡 AI Lab
        String result = aipPtu.faceMerge(imagePath, 12);//人臉融合
        String result = aipPtu.faceSticker(imagePath, 27);//大頭貼
        String result = aipPtu.faceAge(imagePath);//顏齡檢測
        System.out.println(result);
    }
}
  • 自然語言處理

TAipNlp是調用騰訊AI中自然語言處理的Java客戶端,爲調用騰訊AI中自然語言處理功能的開發人員提供了一系列的交互方法。

用戶可以參考如下代碼新建一個 TAipNlp,初始化完成後建議單例使用:

public class Sample{
    public static final String APP_ID = "你的 App ID";
    public static final String APP_KEY = "你的 Api Key";
    public static void main2(String[] args) throws Exception {
        TAipNlp aipNlp = new TAipNlp(APP_ID, APP_KEY);
        String session = new Date().getTime()/1000+"";
        String filePath = "G:/tt.jpg";
        String filePath2 = "G:/16.pcm";
        String result = aipNlp.nlpWordseg("小帥開發者");//分詞
        String result = aipNlp.nlpWordpos("小帥是一個熱心的開發者");//詞性標註
        String result = aipNlp.nlpWordner("最近張學友在深圳開了一場演唱會");//專有名詞
        String result = aipNlp.nlpWordsyn("今天的天氣怎麼樣");//同義詞
        String result = aipNlp.nlpWordcom("今天深圳的天氣怎麼樣?明天呢");//意圖成分
        String result = aipNlp.nlpTextpolar("小帥很帥");//情感分析
        String result = aipNlp.nlpTextchat(session,"北京天氣");//基礎閒聊     
        String result = aipNlp.nlpTextTrans(0, "小帥開發者");//文本翻譯(AI Lab)
        String result = aipNlp.nlpTextTranslate("小帥開發者", "zh", "en");//文本翻譯(翻譯君)     
        String result = aipNlp.nlpImageTranslate(filePath, session, "doc","zh", "en");//圖片翻譯
        String result = aipNlp.nlpSpeechTranslate(6, 0, 1, session, filePath2,"zh", "en");//語音翻譯     
        String result = aipNlp.nlpTextDetect("こんにちは", 0);//語種識別
        System.out.println(result);
    }
}
  • 智能鑑黃、暴恐圖片識別

TAipVision是調用騰訊AI中智能鑑黃、暴恐圖片識別的Java客戶端,爲調用騰訊AI中智能鑑黃、暴恐圖片識別功能的開發人員提供了一系列的交互方法。

用戶可以參考如下代碼新建一個 TAipVision,初始化完成後建議單例使用:

public class Sample{
    public static final String APP_ID = "你的 App ID";
    public static final String APP_KEY = "你的 Api Key";
    public static void main2(String[] args) throws Exception {
        TAipVision aipVision = new TAipVision(APP_ID, APP_KEY);
        String filePath = "G:/tt.jpg";
        String result = aipVision.imageTerrorism(filePath);//暴恐圖片
        String result = aipVision.visionPorn(filePath);//智能鑑黃
        System.out.println(result);
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章