使用Maven 导入JavaCV包:
```handlebars
<!-- https://mvnrepository.com/artifact/org.bytedeco/javacv-platform -->
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacv-platform</artifactId>
<version>1.5.4</version>
</dependency>
然后传入验证码放置的路径,批量读取验证码并返回字符串。
public class opencvImageDemo {
public String handleImage(String imageFile) throws IOException, TesseractException, InterruptedException {
Mat image = imread(imageFile);
File fileObj = new File(imageFile);
String orignialFile= imageFile.substring(0,imageFile.indexOf("."));
Mat grayImage = new Mat();
Mat result = new Mat();
//灰度化
cvtColor(image, grayImage,CV_BGR2GRAY);
//二值化
threshold