当前位置:网站首页>With this tool, automatic identification and verification code is no longer a problem
With this tool, automatic identification and verification code is no longer a problem
2022-06-29 01:10:00 【Xiaowu knock code】
Environmental preparation
1、windows Environment Download exe
http://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-setup-4.00.00dev.exe
double-click exe, All the way next complete Tesseract-OCR install 


2、 Configure environment variables
PATH increase D:\ProgramFiles\Tesseract-OCR
New environment variable TESSDATA_PREFIX The value is
D:\ProgramFiles\Tesseract-OCR\tessdata
This is to add the Language Library folder to the environment variable TESSDATA_PREFIX in
CMD In the command line window, enter the following command :
View version number
C:\Users\18611>tesseract -v
tesseract 4.00.00alpha
leptonica-1.74.1
libgif 4.1.6(?) : libjpeg 8d (libjpeg-turbo 1.5.0) : libpng 1.6.20: libtiff 4.0.6 : zlib 1.2.8 :
libwebp 0.4.3 : libopenjp2 2.1.0
View supported language packs
C:\Users\18611>tesseract --list-langs
List of available languages (2):
eng
osd
C:\Users\18611>
Command recognition picture
Identify the following picture verification code

Use tesseract The command recognizes the contents of the picture
C:\Users\18611>cd Desktop
C:\Users\18611\Desktop>tesseract test2.png output
Tesseract Open Source OCR Engine v4.00.00alpha with Leptonica
C:\Users\18611\Desktop>
【 grammar 】:tesseract imagename outputbase [-l lang] [-psm pagesegmode] [configfile…]
imagename For the target image file name , Format suffix is needed ;
outputbase Is the conversion result file name ;
lang Is the language name ( stay Tesseract-OCR in tessdata The folder can be seen as eng The first language file eng.traineddata), If not marked -l eng The default is eng.
java Automatically recognize pictures
take tesseract.exe Save command as bat file ,bat The content is :
// Picture path D:\Tesseract-OCR\test.png Generate txt File storage path and file name result
The code implementation is as follows :
package com.mtx.util;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
/** * @ClassName ReadCpacha * @Description TODO * @Author The colours of the rainbow rainbow QQ3130978832 * @Date-Time 2022/6/9 13:55 * @ProjectName MtxPublic * @Copyright Beijing Code classmate Network Technology Co., Ltd **/
public class ReadCpacha{
public static String readPic(){
String cmd= "cmd /c start D:\\Tesseract-OCR\\tesseract.bat";
try {
Runtime.getRuntime().exec(cmd);
} catch(Exception e) {
e.printStackTrace();
}
try {
// Thread blocking 3 Seconds to wait tesseract.exe Execution completed
Thread.sleep(3000);
}catch (InterruptedException e) {
e.printStackTrace();
}
// perform tesseract.exe Generate... After identifying the picture result.txt Save the post identification verification code in the file
// Read result.txt Get the verification code from the file
// ReadTxt
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
StringBuffer sb= new StringBuffer();
String text = null;
while((text = bufferedReader.readLine()) != null){
// The string read line by line is saved to StringBuffer object
sb.append(text);
}
return sb.toString();
}catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
public static void main(String[] args) {
String str = readPic();// Call the encapsulated method test
System.out.println(str);
}
}
C:\Users\18611\IdeaProjects\MtxPublic>tesseract --help-psm
Page segmentation modes:
0 Orientation and script detection (OSD) only.
1 Automatic page segmentation with OSD.
2 Automatic page segmentation, but no OSD, or OCR.
3 Fully automatic page segmentation, but no OSD. (Default)
4 Assume a single column of text of variable sizes.
5 Assume a single uniform block of vertically aligned text.
6 Assume a single uniform block of text.
7 Treat the image as a single text line.
8 Treat the image as a single word.
9 Treat the image as a single word in a circle.
10 Treat the image as a single character.
11 Sparse text. Find as much text as possible in no particular order.
12 Sparse text with OSD.
13 Raw line. Treat the image as a single text line, bypassing hacks that are Tesseract-specific.
C:\Users\18611\IdeaProjects\MtxPublic>
Finally, thank everyone who reads my article carefully , The following online link is also a very comprehensive one that I spent a few days sorting out , I hope it can also help you in need !

These materials , For those who want to change careers 【 software test 】 For our friends, it should be the most comprehensive and complete war preparation warehouse , This warehouse also accompanied me through the most difficult journey , I hope it can help you ! Everything should be done as soon as possible , Especially in the technology industry , We must improve our technical skills . I hope that's helpful ……
If you don't want to grow up alone , Unable to find the information of the system , The problem is not helped , If you insist on giving up after a few days , You can click the small card below to join our group , We can discuss and exchange , There will be various software testing materials and technical exchanges .
| Click the small card at the end of the document to receive it |
Typing is not easy , If this article is helpful to you , Click a like, collect a hide and pay attention , Give the author an encouragement . It's also convenient for you to find it quickly next time .
Self study recommendation B Stop video :
Zero basis transition software testing :25 Days from zero basis to software testing post , I finished today , Employment tomorrow .【 Include features / Interface / automation /python automated testing / performance / Test Development 】
Advanced automation testing :2022B The first station is super detailed python Practical course of automated software testing , Prepare for the golden, silver and four job hopping season , After advanced learning, it soared 20K
边栏推荐
- 【UVM】我的 main_phase 都跑完了,为啥 case 无法退出?太不讲道理!
- 狼人杀休闲游戏微信小程序模板源码/微信小游戏源码
- 企业和IT领导者对创新的误解
- Finally understand the difference between DOM XSS and reflection XSS
- It is safer for individuals to choose a securities company to open an account when buying interbank certificates of deposit
- EasyCVR服务private.pem文件被清空,导致无法正常启动该如何处理?
- How to calculate the income tax of foreign-funded enterprises
- Do280 allocating persistent storage
- Browser cache library design summary (localstorage/indexeddb)
- [Fire Detection] forest fire detection system based on Matlab GUI (with panel) [including Matlab source code phase 1921]
猜你喜欢

What is the reason for the service crash caused by replacing the easycvr cluster version with the old database?

Jbridge bridging frame technology for AI computing power landing

GUI Graphical user interface programming example - color selection box

DO280分配持久性存储

统计学习方法(3/22)K近邻法

Redis常用命令手册
![[Fire Detection] forest fire detection system based on Matlab GUI (with panel) [including Matlab source code phase 1921]](/img/fa/17731d46a70112faadbfd0e61be143.png)
[Fire Detection] forest fire detection system based on Matlab GUI (with panel) [including Matlab source code phase 1921]

Analysis Framework -- establishment of user experience measurement data system

sql入门

EasyCVR集群版本替换成老数据库造成的服务崩溃是什么原因?
随机推荐
How to handle a SIGTERM - how to handle a SIGTERM
EasyCVR接入Ehome协议的设备,无法观看设备录像是什么原因?
cocoscreator动态切换SkeletonData实现骨骼更新
Misunderstanding of innovation by enterprise and it leaders
第八天 脚本与音频
Uvm:factory mechanism
免疫组化和免疫组学之间的区别是啥?
Large-scale case applications to developing post-click conversion rate estimation with MTL
Depth first search to realize the problem of catching cattle
Two ways to set up a single Nacos load balancing ribbon polling policy weight
be based on. NETCORE development blog project starblog - (13) add friendship link function
Browser cache library design summary (localstorage/indexeddb)
[temperature detection] thermal infrared image temperature detection system based on Matlab GUI [including Matlab source code 1920]
How to solve the problem of Caton screen when easycvr plays video?
What is the reason why easycvr can't watch the device video when it is connected to the home protocol?
What is the difference between the history and Western blotting
What is the reason for the service crash caused by replacing the easycvr cluster version with the old database?
Breadth first search to catch cattle
How to calculate the income tax of foreign-funded enterprises
[RRT 3D path planning] rapid expansion of random tree UAV 3D path planning based on MATLAB [including Matlab source code phase 1914]