不到十行實(shí)現(xiàn)javaCV圖片OCR文字識(shí)別
spring boot項(xiàng)目pom文件中添加以下依賴
<!-- https://mvnrepository.com/artifact/org.bytedeco/javacv-platform --> <dependency> <groupId>org.bytedeco</groupId> <artifactId>javacv-platform</artifactId> <version>1.5.5</version> </dependency>
單類代碼實(shí)現(xiàn),復(fù)制到idea編輯器里,右鍵run運(yùn)行即可。
OCR方法參數(shù)說明,
1.lng 語言類型 分為兩種 1.eng 英語 2.chi_sim 中文簡體
2.dataPath 語言數(shù)據(jù)集文件夾路徑
3.imagePath 需要識(shí)別的圖片文件路徑
import org.bytedeco.javacpp.BytePointer; import org.bytedeco.leptonica.PIX; import org.bytedeco.leptonica.global.lept; import org.bytedeco.tesseract.TessBaseAPI; public class OcrTest { public static String OCR(String lng,String dataPath,String imagePath) { TessBaseAPI api=new TessBaseAPI(); if (api.Init(dataPath, lng)!=0){ System.out.println("error"); } PIX image= lept.pixRead(imagePath); if (image==null){ return ""; } api.SetImage(image); BytePointer outText=api.GetUTF8Text(); String result=outText.getString(); api.End(); outText.deallocate(); lept.pixDestroy(image); return result; } public static void main(String[] args) { String text= OCR("chi_sim", "E:\\traineddata", "C:\\Users\\tarzan\\Desktop\\image\\test5.png"); System.out.println(text); } }
測試樣例結(jié)果
test1.jpg
test2.jpg
test3.jpg
test4.jpg
test5.jpg
到此這篇關(guān)于不到十行實(shí)現(xiàn)javaCV圖片OCR文字識(shí)別的文章就介紹到這了,更多相關(guān)javaCV OCR文字識(shí)別內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- java實(shí)現(xiàn)圖片文字識(shí)別ocr
- Java使用Tesseract-Ocr識(shí)別數(shù)字
- Java使用OCR技術(shù)識(shí)別驗(yàn)證碼實(shí)現(xiàn)自動(dòng)化登陸方法
- Java使用Tessdata做OCR圖片文字識(shí)別的詳細(xì)思路
- java實(shí)現(xiàn)騰訊ocr圖片識(shí)別接口調(diào)用
- Java中實(shí)現(xiàn)OCR識(shí)別讀取圖片中的文字
- 用Java實(shí)現(xiàn)OCR功能揭秘
- java中實(shí)現(xiàn)OCR文字提取的幾種方法(Tesseract、PaddleOCR及RapidOCR)
相關(guān)文章
SpringBoot用JdbcTemplates操作Mysql實(shí)例代碼詳解
JdbcTemplate是Spring框架自帶的對JDBC操作的封裝,目的是提供統(tǒng)一的模板方法使對數(shù)據(jù)庫的操作更加方便、友好,效率也不錯(cuò),這篇文章主要介紹了SpringBoot用JdbcTemplates操作Mysql2022-10-10Java設(shè)計(jì)模塊系列之書店管理系統(tǒng)單機(jī)版(三)
這篇文章主要為大家詳細(xì)介紹了Java單機(jī)版的書店管理系統(tǒng)設(shè)計(jì)模塊和思想第三章,感興趣的小伙伴們可以參考一下2016-08-08SpringBoot如何實(shí)現(xiàn)接口版本控制
這篇文章主要介紹了SpringBoot如何實(shí)現(xiàn)接口版本控制,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-10-10Spring Boot thymeleaf模板引擎的使用詳解
這篇文章主要介紹了Spring Boot thymeleaf模板引擎的使用詳解,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-03-03Java三種方法將List轉(zhuǎn)換為Map的實(shí)例
今天小編就為大家分享一篇關(guān)于Java三種方法將List轉(zhuǎn)換為Map的實(shí)例,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧2018-10-10