用Asprise的OCR包,处理验证码 (一)

2014-11-24 11:03:50 · 作者: · 浏览: 0

今天要介绍Java的OCR(图片字符识别)包,由Asprise出品。它甚至可以读条形码。

请从下面的链接下载包含破解的zip文件。

这个包用起来非常简单。

解开上面的zip后,里面有demo-src.jar,把这个jar也解开,打开 com/asprise/util/ocr/demo/Demo.java 看看,就全明白了:

/*

* $Id$
*
*/
package com.asprise.util.ocr.demo;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.asprise.util.ocr.OCR;
public class Demo {
public static void main(String[] args) throws IOException {
if(("1.4").compareTo(System.getProperty("java.vm.version")) > 0) {
System.err.println("Warining: /n/nYou need Java version 1.4 or above for ImageIO to run this demo.");
System.err.println("Your current Java version is: " + System.getProperty("java.vm.version"));
System.err.println("/nSolutions: /n");
System.err.println("(1) Download JRE/JDK version 1.4 or above; OR /n");
System.err.println("(2) Run DemoUI, which can run on your current Java virtual machine.");
System.err.println(" Double click the 'runDemoUI' to invoke it./n");
return;
}
System.out.println("Welcome to Asprise OCR v4.0 Demo!/n");
if(args.length < 1) {
System.err.println("Usage: java Demo PATH_TO_IMAGE [Description]");
return;
}

if(args.length >= 2) {
System.out.println("-----------------------------------------------------------");
for(int i=1; i System.out.println(args[i]);
System.out.println("-----------------------------------------------------------/n");
}

File file = new File(args[0]);

System.out.println("Trying to perform OCR on image: " + file.getAbsolutePath());

//OCR.setLibraryPath("E:/Twain/OCR/OCR+i/Release/AspriseOCR.dll");
BufferedImage image =
ImageIO.read(file);
String s = new OCR().recognizeEverything(image);
System.out.println("/n---- RESULTS: ------- /n" + s);
}

}
[java] /*
* $Id$
*
*/
package com.asprise.util.ocr.demo;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.asprise.util.ocr.OCR;
public class Demo {
public static void main(String[] args) throws IOException {
if(("1.4").compareTo(System.getProperty("java.vm.version")) > 0) {
System.err.println("Warining: /n/nYou need Java version 1.4 or above for ImageIO to run this demo.");
System.err.println("Your current Java version is: " + System.getProperty("java.vm.version"));
System.err.println("/nSolutions: /n");
System.err.println("(1) Download JRE/JDK version 1.4 or above; OR /n");
System.err.println("(2) Run DemoUI, which can run on your current Java virtual machine.");
System.err.println(" Double click the 'runDemoUI' to invoke it./n");
return;
}
System.out.println("Welcome to Asprise OCR v4.0 Demo!/n");
if(args.length < 1) {
System.err.println("Usage: java Demo PATH_TO_IMAGE [Description]");
return;
}

if(args.length >= 2) {
System.out.print