In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "Android how to achieve picture text recognition". In daily operation, I believe many people have doubts about how to achieve picture text recognition in Android. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to achieve picture text recognition in Android". Next, please follow the editor to study!
Runnable steps
1. Add dependencies
Implementation "com.rmtheis:tess-two:8.0.0"
2. Download the font recognition library (chi_sim.traineddata Chinese simplified, chi_tra.traineddata Chinese traditional, eng.traineddata English library)
3. For the size of apk, we need to copy the font recognition library file to the SD card directory, such as eng.traineddata copy
Private String mDataPath = Environment.getExternalStorageDirectory (). GetAbsolutePath () + File.separator;private String mFilePath = mDataPath + File.separator + "tessdata" + File.separator + "eng.traineddata"; private void copyFile () {try {File mFile = new File (mFilePath); if (mFile.exists ()) {mFile.delete () } if (! mFile.exists ()) {File p = new File (mFile.getParent ()); if (! p.exists ()) {p.mkdirs ();} try {mFile.createNewFile () } catch (IOException e) {e.printStackTrace ();}} OutputStream os = new FileOutputStream (mFilePath); InputStream is = this.getAssets (). Open ("eng.traineddata"); byte [] buffer = new byte [1024]; int len = 0 While ((len = is.read (buffer))! =-1) {os.write (buffer, 0, len);} os.flush (); os.close (); is.close ();} catch (Exception e) {e.printStackTrace ();}}
4. Tess two initialization
TessBaseAPI baseApi;baseApi = new TessBaseAPI (); baseApi.init (mDataPath, "eng")
5. Process bitmap images and identify their contents
/ / OCR picture text recognition baseApi.setImage (bitmap); String result = baseApi.getUTF8Text (). Replace ("", ") .toLowerCase (); at this point, the study on" how to achieve picture text recognition in Android "is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.