- 浏览: 54880 次
- 性别:
- 来自: 深圳
最新评论
-
u013562896:
根本跑步了,代码有问题,差评
验证码的OCR方式识别 -
zxysh10034:
我的jar包下载了但是运行还是不行,不报错:Exit valu ...
验证码的OCR方式识别 -
sun_34:
大仙帮我看看 SLF4J: Failed to load cl ...
验证码的OCR方式识别 -
sun_34:
我这也报各种异常 希望楼主帮忙[img][/img]
验证码的OCR方式识别 -
缘来是你:
Exception in thread "main& ...
验证码的OCR方式识别
关于Java的验证码识别方面不是太多,有的大多是基于特征码提取的.最近要自动登录网站抓取数据,使用了OCR方式识别的方式处理,记录一下下.
使用的OCR引擎是tesseract,冒得别地选了.
此引擎的优点重复下,字母类语言的识别率几乎可达100%,前提是图像最好黑白(二值化过地),噪点少地图,测试时发现每个字符的高度必须在10个像素以上才能识别.
增强识别率的关键是要识别的验证码图片越干净越好,为此准备了六种图像过滤,用以滤干净图像,有:图像二值化,锐化,中值滤波,线性灰度变换,转黑白灰度图,放大(非平滑缩放).
一般干扰不太严重的验证码,如支付宝使用图像二值化和线性灰度变换就可以做到100%识别,有噪点的才需要中值滤波.
使用这六种过滤的组合应该可以搞定大部分比较弱智的验证码
参考了jtOCR的调用封装
调用很简单的图像过滤:
package net.wealthgod.client.center.ocr; import java.awt.Graphics2D; import java.awt.color.ColorSpace; import java.awt.geom.AffineTransform; import java.awt.image.AffineTransformOp; import java.awt.image.BufferedImage; import java.awt.image.ColorConvertOp; import java.awt.image.ColorModel; import java.awt.image.MemoryImageSource; import java.awt.image.PixelGrabber; public class ImageFilter { private BufferedImage image; private int iw, ih; private int[] pixels; public ImageFilter(BufferedImage image) { this.image = image; iw = image.getWidth(); ih = image.getHeight(); pixels = new int[iw * ih]; } /** 图像二值化 */ public BufferedImage changeGrey() { PixelGrabber pg = new PixelGrabber(image.getSource(), 0, 0, iw, ih, pixels, 0, iw); try { pg.grabPixels(); } catch (InterruptedException e) { e.printStackTrace(); } // 设定二值化的域值,默认值为100 int grey = 100; // 对图像进行二值化处理,Alpha值保持不变 ColorModel cm = ColorModel.getRGBdefault(); for (int i = 0; i < iw * ih; i++) { int red, green, blue; int alpha = cm.getAlpha(pixels[i]); if (cm.getRed(pixels[i]) > grey) { red = 255; } else { red = 0; } if (cm.getGreen(pixels[i]) > grey) { green = 255; } else { green = 0; } if (cm.getBlue(pixels[i]) > grey) { blue = 255; } else { blue = 0; } pixels[i] = alpha << 24 | red << 16 | green << 8 | blue; } // 将数组中的象素产生一个图像 return ImageIOHelper.imageProducerToBufferedImage(new MemoryImageSource(iw, ih, pixels, 0, iw)); } /** 提升清晰度,进行锐化 */ public BufferedImage sharp() { PixelGrabber pg = new PixelGrabber(image.getSource(), 0, 0, iw, ih, pixels, 0, iw); try { pg.grabPixels(); } catch (InterruptedException e) { e.printStackTrace(); } // 象素的中间变量 int tempPixels[] = new int[iw * ih]; for (int i = 0; i < iw * ih; i++) { tempPixels[i] = pixels[i]; } // 对图像进行尖锐化处理,Alpha值保持不变 ColorModel cm = ColorModel.getRGBdefault(); for (int i = 1; i < ih - 1; i++) { for (int j = 1; j < iw - 1; j++) { int alpha = cm.getAlpha(pixels[i * iw + j]); // 对图像进行尖锐化 int red6 = cm.getRed(pixels[i * iw + j + 1]); int red5 = cm.getRed(pixels[i * iw + j]); int red8 = cm.getRed(pixels[(i + 1) * iw + j]); int sharpRed = Math.abs(red6 - red5) + Math.abs(red8 - red5); int green5 = cm.getGreen(pixels[i * iw + j]); int green6 = cm.getGreen(pixels[i * iw + j + 1]); int green8 = cm.getGreen(pixels[(i + 1) * iw + j]); int sharpGreen = Math.abs(green6 - green5) + Math.abs(green8 - green5); int blue5 = cm.getBlue(pixels[i * iw + j]); int blue6 = cm.getBlue(pixels[i * iw + j + 1]); int blue8 = cm.getBlue(pixels[(i + 1) * iw + j]); int sharpBlue = Math.abs(blue6 - blue5) + Math.abs(blue8 - blue5); if (sharpRed > 255) { sharpRed = 255; } if (sharpGreen > 255) { sharpGreen = 255; } if (sharpBlue > 255) { sharpBlue = 255; } tempPixels[i * iw + j] = alpha << 24 | sharpRed << 16 | sharpGreen << 8 | sharpBlue; } } // 将数组中的象素产生一个图像 return ImageIOHelper.imageProducerToBufferedImage(new MemoryImageSource(iw, ih, tempPixels, 0, iw)); } /** 中值滤波 */ public BufferedImage median() { PixelGrabber pg = new PixelGrabber(image.getSource(), 0, 0, iw, ih, pixels, 0, iw); try { pg.grabPixels(); } catch (InterruptedException e) { e.printStackTrace(); } // 对图像进行中值滤波,Alpha值保持不变 ColorModel cm = ColorModel.getRGBdefault(); for (int i = 1; i < ih - 1; i++) { for (int j = 1; j < iw - 1; j++) { int red, green, blue; int alpha = cm.getAlpha(pixels[i * iw + j]); // int red2 = cm.getRed(pixels[(i - 1) * iw + j]); int red4 = cm.getRed(pixels[i * iw + j - 1]); int red5 = cm.getRed(pixels[i * iw + j]); int red6 = cm.getRed(pixels[i * iw + j + 1]); // int red8 = cm.getRed(pixels[(i + 1) * iw + j]); // 水平方向进行中值滤波 if (red4 >= red5) { if (red5 >= red6) { red = red5; } else { if (red4 >= red6) { red = red6; } else { red = red4; } } } else { if (red4 > red6) { red = red4; } else { if (red5 > red6) { red = red6; } else { red = red5; } } } // int green2 = cm.getGreen(pixels[(i - 1) * iw + j]); int green4 = cm.getGreen(pixels[i * iw + j - 1]); int green5 = cm.getGreen(pixels[i * iw + j]); int green6 = cm.getGreen(pixels[i * iw + j + 1]); // int green8 = cm.getGreen(pixels[(i + 1) * iw + j]); // 水平方向进行中值滤波 if (green4 >= green5) { if (green5 >= green6) { green = green5; } else { if (green4 >= green6) { green = green6; } else { green = green4; } } } else { if (green4 > green6) { green = green4; } else { if (green5 > green6) { green = green6; } else { green = green5; } } } // int blue2 = cm.getBlue(pixels[(i - 1) * iw + j]); int blue4 = cm.getBlue(pixels[i * iw + j - 1]); int blue5 = cm.getBlue(pixels[i * iw + j]); int blue6 = cm.getBlue(pixels[i * iw + j + 1]); // int blue8 = cm.getBlue(pixels[(i + 1) * iw + j]); // 水平方向进行中值滤波 if (blue4 >= blue5) { if (blue5 >= blue6) { blue = blue5; } else { if (blue4 >= blue6) { blue = blue6; } else { blue = blue4; } } } else { if (blue4 > blue6) { blue = blue4; } else { if (blue5 > blue6) { blue = blue6; } else { blue = blue5; } } } pixels[i * iw + j] = alpha << 24 | red << 16 | green << 8 | blue; } } // 将数组中的象素产生一个图像 return ImageIOHelper.imageProducerToBufferedImage(new MemoryImageSource(iw, ih, pixels, 0, iw)); } /** 线性灰度变换 */ public BufferedImage lineGrey() { PixelGrabber pg = new PixelGrabber(image.getSource(), 0, 0, iw, ih, pixels, 0, iw); try { pg.grabPixels(); } catch (InterruptedException e) { e.printStackTrace(); } // 对图像进行进行线性拉伸,Alpha值保持不变 ColorModel cm = ColorModel.getRGBdefault(); for (int i = 0; i < iw * ih; i++) { int alpha = cm.getAlpha(pixels[i]); int red = cm.getRed(pixels[i]); int green = cm.getGreen(pixels[i]); int blue = cm.getBlue(pixels[i]); // 增加了图像的亮度 red = (int) (1.1 * red + 30); green = (int) (1.1 * green + 30); blue = (int) (1.1 * blue + 30); if (red >= 255) { red = 255; } if (green >= 255) { green = 255; } if (blue >= 255) { blue = 255; } pixels[i] = alpha << 24 | red << 16 | green << 8 | blue; } // 将数组中的象素产生一个图像 return ImageIOHelper.imageProducerToBufferedImage(new MemoryImageSource(iw, ih, pixels, 0, iw)); } /** 转换为黑白灰度图 */ public BufferedImage grayFilter() { ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY); ColorConvertOp op = new ColorConvertOp(cs, null); return op.filter(image, null); } /** 平滑缩放 */ public BufferedImage scaling(double s) { AffineTransform tx = new AffineTransform(); tx.scale(s, s); AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR); return op.filter(image, null); } public BufferedImage scale(Float s) { int srcW = image.getWidth(); int srcH = image.getHeight(); int newW = Math.round(srcW * s); int newH = Math.round(srcH * s); // 先做水平方向上的伸缩变换 BufferedImage tmp=new BufferedImage(newW, newH, image.getType()); Graphics2D g= tmp.createGraphics(); for (int x = 0; x < newW; x++) { g.setClip(x, 0, 1, srcH); // 按比例放缩 g.drawImage(image, x - x * srcW / newW, 0, null); } // 再做垂直方向上的伸缩变换 BufferedImage dst = new BufferedImage(newW, newH, image.getType()); g = dst.createGraphics(); for (int y = 0; y < newH; y++) { g.setClip(0, y, newW, 1); // 按比例放缩 g.drawImage(tmp, 0, y - y * srcH / newH, null); } return dst; } }
图形对象之间的转换:
/* * ImageIOHelper.java * * Created on December 24, 2007, 1:15 AM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package net.wealthgod.client.center.ocr; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.awt.image.DataBufferByte; import java.awt.image.ImageProducer; import java.awt.image.WritableRaster; import java.io.File; import java.io.IOException; import java.util.Iterator; import java.util.Locale; import javax.imageio.IIOImage; import javax.imageio.ImageIO; import javax.imageio.ImageReader; import javax.imageio.ImageWriteParam; import javax.imageio.ImageWriter; import javax.imageio.metadata.IIOMetadata; import javax.imageio.stream.ImageInputStream; import javax.imageio.stream.ImageOutputStream; import javax.swing.JOptionPane; import com.sun.media.imageio.plugins.tiff.TIFFImageWriteParam; public class ImageIOHelper { public ImageIOHelper() { } public static File createImage(File imageFile, String imageFormat) { File tempFile = null; try { Iterator<ImageReader> readers = ImageIO.getImageReadersByFormatName(imageFormat); ImageReader reader = readers.next(); ImageInputStream iis = ImageIO.createImageInputStream(imageFile); reader.setInput(iis); // Read the stream metadata IIOMetadata streamMetadata = reader.getStreamMetadata(); // Set up the writeParam TIFFImageWriteParam tiffWriteParam = new TIFFImageWriteParam(Locale.US); tiffWriteParam.setCompressionMode(ImageWriteParam.MODE_DISABLED); // Get tif writer and set output to file Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("tiff"); ImageWriter writer = writers.next(); BufferedImage bi = reader.read(0); IIOImage image = new IIOImage(bi, null, reader.getImageMetadata(0)); tempFile = tempImageFile(imageFile); ImageOutputStream ios = ImageIO.createImageOutputStream(tempFile); writer.setOutput(ios); writer.write(streamMetadata, image, tiffWriteParam); ios.close(); writer.dispose(); reader.dispose(); } catch (Exception exc) { exc.printStackTrace(); } return tempFile; } public static File createImage(BufferedImage bi) { File tempFile = null; try { tempFile = File.createTempFile("tempImageFile", ".tif"); tempFile.deleteOnExit(); TIFFImageWriteParam tiffWriteParam = new TIFFImageWriteParam(Locale.US); tiffWriteParam.setCompressionMode(ImageWriteParam.MODE_DISABLED); // Get tif writer and set output to file Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("tiff"); ImageWriter writer = writers.next(); IIOImage image = new IIOImage(bi, null, null); tempFile = tempImageFile(tempFile); ImageOutputStream ios = ImageIO.createImageOutputStream(tempFile); writer.setOutput(ios); writer.write(null, image, tiffWriteParam); ios.close(); writer.dispose(); } catch (Exception exc) { exc.printStackTrace(); } return tempFile; } public static File tempImageFile(File imageFile) { String path = imageFile.getPath(); StringBuffer strB = new StringBuffer(path); strB.insert(path.lastIndexOf('.'), 0); return new File(strB.toString().replaceFirst("(?<=\\.)(\\w+)$", "tif")); } public static BufferedImage getImage(File imageFile) { BufferedImage al = null; try { String imageFileName = imageFile.getName(); String imageFormat = imageFileName.substring(imageFileName.lastIndexOf('.') + 1); Iterator<ImageReader> readers = ImageIO.getImageReadersByFormatName(imageFormat); ImageReader reader = readers.next(); if (reader == null) { JOptionPane.showConfirmDialog(null, "Need to install JAI Image I/O package.\nhttps://jai-imageio.dev.java.net"); return null; } ImageInputStream iis = ImageIO.createImageInputStream(imageFile); reader.setInput(iis); al = reader.read(0); reader.dispose(); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } catch (Exception e) { System.err.println(e.getMessage()); } return al; } public static BufferedImage imageToBufferedImage(Image image) { BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB); Graphics2D g = bufferedImage.createGraphics(); g.drawImage(image, 0, 0, null); return bufferedImage; } public static BufferedImage imageProducerToBufferedImage(ImageProducer imageProducer) { return imageToBufferedImage(Toolkit.getDefaultToolkit().createImage(imageProducer)); } public static byte[] image_byte_data(BufferedImage image) { WritableRaster raster = image.getRaster(); DataBufferByte buffer = (DataBufferByte) raster.getDataBuffer(); return buffer.getData(); } }
OCR 调用:
/* * OCR.java * * Created on December 24, 2007, 12:38 AM */ package net.wealthgod.client.center.ocr; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class OCR { protected transient final Logger logger = LoggerFactory.getLogger(this.getClass()); private final String LANG_OPTION = "-l"; private final String EOL = System.getProperty("line.separator"); private String tessPath = new File("tesseract").getAbsolutePath(); public String recognizeText(File imageFile, String imageFormat) throws Exception { File tempImage = ImageIOHelper.createImage(imageFile, imageFormat); File outputFile = new File(imageFile.getParentFile(), "output"); StringBuffer strB = new StringBuffer(); List<String> cmd = new ArrayList<String>(); cmd.add(tessPath + "\\tesseract"); cmd.add(""); cmd.add(outputFile.getName()); cmd.add(LANG_OPTION); cmd.add("eng"); ProcessBuilder pb = new ProcessBuilder(); pb.directory(imageFile.getParentFile()); cmd.set(1, tempImage.getName()); pb.command(cmd); pb.redirectErrorStream(true); Process process = pb.start(); int w = process.waitFor(); logger.debug("Exit value = {}", w); // delete temp working files tempImage.delete(); if (w == 0) { BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(outputFile .getAbsolutePath() + ".txt"), "UTF-8")); String str; while ((str = in.readLine()) != null) { strB.append(str).append(EOL); } in.close(); } else { String msg; switch (w) { case 1: msg = "Errors accessing files. There may be spaces in your image's filename."; break; case 29: msg = "Cannot recognize the image or its selected region."; break; case 31: msg = "Unsupported image format."; break; default: msg = "Errors occurred."; } tempImage.delete(); throw new RuntimeException(msg); } new File(outputFile.getAbsolutePath() + ".txt").delete(); logger.info("图像识别结果:{}", strB); return strB.toString(); } }
- ocr-src.rar (1.3 MB)
- 下载次数: 6036
评论
31 楼
u013562896
2016-09-23
根本跑步了,代码有问题,差评
30 楼
zxysh10034
2014-12-02
我的jar包下载了但是运行还是不行,不报错:
Exit value = 0
图像识别结果:{}
Exit value = 0
图像识别结果:{}
29 楼
sun_34
2014-08-12
大仙帮我看看
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
org.testng.TestNGException:
Cannot instantiate class script.Demo
at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:38)
at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:387)
at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:299)
at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:110)
at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:186)
at org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:120)
at org.testng.TestRunner.initMethods(TestRunner.java:409)
at org.testng.TestRunner.init(TestRunner.java:235)
at org.testng.TestRunner.init(TestRunner.java:205)
at org.testng.TestRunner.<init>(TestRunner.java:160)
at org.testng.remote.RemoteTestNG$1.newTestRunner(RemoteTestNG.java:141)
at org.testng.remote.RemoteTestNG$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG.java:271)
at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:561)
at org.testng.SuiteRunner.init(SuiteRunner.java:157)
at org.testng.SuiteRunner.<init>(SuiteRunner.java:111)
at org.testng.TestNG.createSuiteRunner(TestNG.java:1299)
at org.testng.TestNG.createSuiteRunners(TestNG.java:1286)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:29)
... 21 more
Caused by: java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:230)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:121)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:112)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:275)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:248)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:261)
at util.OCR.<init>(OCR.java:21)
at script.Demo.<init>(Demo.java:23)
... 26 more
Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 34 more
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
org.testng.TestNGException:
Cannot instantiate class script.Demo
at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:38)
at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:387)
at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:299)
at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:110)
at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:186)
at org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:120)
at org.testng.TestRunner.initMethods(TestRunner.java:409)
at org.testng.TestRunner.init(TestRunner.java:235)
at org.testng.TestRunner.init(TestRunner.java:205)
at org.testng.TestRunner.<init>(TestRunner.java:160)
at org.testng.remote.RemoteTestNG$1.newTestRunner(RemoteTestNG.java:141)
at org.testng.remote.RemoteTestNG$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG.java:271)
at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:561)
at org.testng.SuiteRunner.init(SuiteRunner.java:157)
at org.testng.SuiteRunner.<init>(SuiteRunner.java:111)
at org.testng.TestNG.createSuiteRunner(TestNG.java:1299)
at org.testng.TestNG.createSuiteRunners(TestNG.java:1286)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:29)
... 21 more
Caused by: java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:230)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:121)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:112)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:275)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:248)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:261)
at util.OCR.<init>(OCR.java:21)
at script.Demo.<init>(Demo.java:23)
... 26 more
Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 34 more
28 楼
sun_34
2014-08-12
我这也报各种异常 希望楼主帮忙
[img][/img]
[img][/img]
27 楼
缘来是你
2014-01-09
Exception in thread "main" java.io.IOException: Cannot run program "D:\Tesseract-OCR\tesseract" (in directory "D:\"): CreateProcess error=5, at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
at com.ocr.OCR.recognizeText(OCR.java:53)
at com.ocr.Test.main(Test.java:9)
Caused by: java.io.IOException: CreateProcess error=5, at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
... 2 more
at com.ocr.OCR.recognizeText(OCR.java:53)
at com.ocr.Test.main(Test.java:9)
Caused by: java.io.IOException: CreateProcess error=5, at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
... 2 more
26 楼
缘来是你
2014-01-09
IMTI_QQ 写道
运行不了呢。
Exception in thread "main" java.io.IOException: Cannot run program "E:\workspace\workspace_image\image\tesseract\tesseract" (in directory "E:\workspace\workspace_image\imgpro\test"): CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(ProcessBuilder.java:459) at net.wealthgod.client.center.ocr.OCR.recognizeText(OCR.java:51) at net.wealthgod.client.center.ocr.OCR.main(OCR.java:96) Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.<init>(ProcessImpl.java:81) at java.lang.ProcessImpl.start(ProcessImpl.java:30) at java.lang.ProcessBuilder.start(ProcessBuilder.java:452) ... 2 more
25 楼
jetlyp
2013-03-14
java.io.IOException: Cannot run program "D:\lypproject\test\tesseract//tesseract" (in directory "D:\temp"): CreateProcess error=5, ???·?
at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
at com.ocr.OCR.recognizeText(OCR.java:81)
at com.ocr.Test.main(Test.java:29)
Caused by: java.io.IOException: CreateProcess error=5, ???·?
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
... 2 more
怎么解决
at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
at com.ocr.OCR.recognizeText(OCR.java:81)
at com.ocr.Test.main(Test.java:29)
Caused by: java.io.IOException: CreateProcess error=5, ???·?
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
... 2 more
怎么解决
24 楼
z1721940401
2012-09-30
rrrrrr
23 楼
niuqiang2008
2012-09-02
恶风而无法
22 楼
xusong_zidingyi
2012-08-21
为什么在linux下面运行不可以,报与12楼一样的错误。代码有缺陷。linux是不能执行.exe文件的,只有在windows下面才可以,但是一般程序都是部署在linux下面的。
21 楼
lujiadontcry
2012-05-11
imageformat
如果填写原始的后缀,jpg的话,填写jpeg等等
陆 Q 66377298(企业短信和彩信)
如果填写原始的后缀,jpg的话,填写jpeg等等
陆 Q 66377298(企业短信和彩信)
20 楼
Aryan
2011-11-03
楼主 加个好友 继续请教
19 楼
lilei9963
2011-11-02
47845154
18 楼
fan7421436
2011-10-17
我在JSP中调用的代码是:
然后报:
NullPointerException
com.m0054.entity.OCR.recognizeText(OCR.java:48)
com.sun.imageio.plugins.jpeg.JPEGImageReader.checkTablesOnly(JPEGImageReader.java:309)
com.m0054.entity.ImageIOHelper.createImage(ImageIOHelper.java:53)
com.m0054.entity.OCR.recognizeText(OCR.java:27)
截了几个重要的报错信息出来
我传的参数file文件不能直接用URL地址嘛?
<% OCR ocr = new OCR(); File file = new File("http://vote.*****.cn/pic.php"); String text = ocr.recognizeText(file,"jpg"); %>
然后报:
NullPointerException
com.m0054.entity.OCR.recognizeText(OCR.java:48)
com.sun.imageio.plugins.jpeg.JPEGImageReader.checkTablesOnly(JPEGImageReader.java:309)
com.m0054.entity.ImageIOHelper.createImage(ImageIOHelper.java:53)
com.m0054.entity.OCR.recognizeText(OCR.java:27)
截了几个重要的报错信息出来
我传的参数file文件不能直接用URL地址嘛?
17 楼
fan7421436
2011-10-17
下载了源码 是调用ORCL类里面的recognizeText()方法吗?
如果是调用recognizeText(File imageFile, String imageFormat)方法,两个参数第一个还懂 第二个参数不知道传什么!
如果是调用recognizeText(File imageFile, String imageFormat)方法,两个参数第一个还懂 第二个参数不知道传什么!
16 楼
javajava22
2011-09-10
Exception in thread "main" java.lang.RuntimeException: Errors accessing files. There may be spaces in your image's filename.
这个错误是因为 tesseract 路径 问题造成的,最好把 tesseract 写死,就可以了
这个错误是因为 tesseract 路径 问题造成的,最好把 tesseract 写死,就可以了
15 楼
dogg
2011-06-13
abin7230 写道
需要下载jai_imageio-1.1-alpha.jar, swingx-1.0.jar这两个JAR包吧
是的
14 楼
abin7230
2011-06-10
需要下载jai_imageio-1.1-alpha.jar, swingx-1.0.jar这两个JAR包吧
13 楼
anyasir
2011-05-31
什么编码方式?utf8?试了好几个都乱码
12 楼
IMTI_QQ
2011-04-12
运行不了呢。
Exception in thread "main" java.io.IOException: Cannot run program "E:\workspace\workspace_image\image\tesseract\tesseract" (in directory "E:\workspace\workspace_image\imgpro\test"): CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(ProcessBuilder.java:459) at net.wealthgod.client.center.ocr.OCR.recognizeText(OCR.java:51) at net.wealthgod.client.center.ocr.OCR.main(OCR.java:96) Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.<init>(ProcessImpl.java:81) at java.lang.ProcessImpl.start(ProcessImpl.java:30) at java.lang.ProcessBuilder.start(ProcessBuilder.java:452) ... 2 more
相关推荐
验证码OCR的实现通常涉及以下几个关键步骤: 1. 图像预处理:验证码图像往往带有各种噪声和干扰,如背景色、线条、扭曲等。因此,在识别前,我们需要对图像进行预处理,包括灰度化、二值化、平滑滤波、边缘检测等...
《OCRServer识别验证码技术详解与性能测试》 验证码(CAPTCHA)作为一种防止自动化程序非法操作的安全机制,在互联网中广泛使用。OCR(Optical Character Recognition,光学字符识别)技术则为解决验证码识别问题...
本文将深入探讨C#实现的OCR(Optical Character Recognition,光学字符识别)验证码识别技术,以及如何利用该技术提高数字验证码的识别率至100%。 验证码的主要目标是区分人类用户与计算机程序,通常表现为一组模糊...
在本案例中,我们关注的是一个PHP实现的简单验证码OCR识别程序。这个程序包旨在帮助用户自动化识别验证码图像中的字符,特别是针对大多数网站的普通验证码设计。 首先,`simpleocr.php`是主要的PHP源代码文件,它...
在本篇文章里小编给大家分享的是关于Java 如何使用 OCR 技术识别验证码实现自动化登陆的相关知识点内容,需要的朋友们学习下。
java 验证码识别 OCR。
OCR图像识别程序,可以;破解简单的网站验证码,比如本站的验证码
在本场景中,我们要讨论的是如何使用C#语言进行OCR验证码识别。 首先,要实现OCR验证码识别,你需要了解以下几个关键知识点: 1. **图像处理**:在识别验证码前,通常需要对图像进行预处理,包括灰度化、二值化、...
在这个OCR小课设中,我们将探讨如何训练一个模型来识别特定类型的验证码,例如CSDN上传页面上的验证码。 首先,我们需要理解验证码的基本结构。验证码通常由一组随机生成的字符组成,这些字符可能是字母、数字或...
在本主题中,“DELPHI本地识别验证码 易语言 OCR DLL”涉及到的是使用Delphi编程语言和易语言,通过OCR(Optical Character Recognition,光学字符识别)技术来识别这些验证码。DLL(Dynamic Link Library)是...
【Umi-OCR识别验证码】是一种利用光学字符识别(OCR,Optical Character Recognition)技术来自动解析和识别图像中的验证码的技术。在网络安全和自动化测试领域,验证码识别是常见且重要的需求,例如登录验证、防...
jmeter使用ocrserver工具自动识别验证码配置
在本案例中,“OCR识别技术验证码识别程序”是一个专门针对动网验证码的解决方案,它利用OCR技术来解析和识别动网论坛系统的验证码图片,从而实现自动化处理。 验证码的主要目的是防止自动化的机器人或恶意软件进行...
3. 后处理:由于OCR识别可能存在错误,因此需要进行后处理,例如去除额外的空格,校正大小写,或者使用模糊匹配算法与预定义的验证码字符集进行比较。 在实际应用中,为了提高识别准确性,可以考虑以下优化策略: -...
在Delphi编程环境下,我们可以利用第三方库如Asprise OCR来实现验证码识别功能。Asprise OCR是一个功能强大的光学字符识别(Optical Character Recognition,OCR)库,能够帮助开发者将图像中的文字转换为可编辑的...
VB OCR文字识别程序是利用Visual Basic编程语言,结合外部OCR(Optical Character Recognition,光学字符识别)服务API来实现的高效文字识别工具。OCR技术能够将图像中的文本转换为可编辑的数据,通常用于处理扫描...
在JMeter中实现OCR识别验证码的过程大致如下: 1. **安装OCR插件**:压缩包可能包含了JMeter插件,用于集成OCR功能。通常需要将插件的`.jars`文件添加到JMeter的`lib`目录下,并重启JMeter使插件生效。 2. **配置...
该项目是一款基于Java和Python语言开发的验证码OCR识别设计源码,共计包含53个文件,涉及12个Java源文件、9个Python脚本、7个SVG图形文件、6个numpy数组文件、4个属性文件、3个Python序列化文件、2个图片文件、1个...
OCR-for-Captcha是一种基于图像验证码的OCR(光学字符识别)技术,旨在自动识别和提取图像验证码中的字符信息。在现实生活中,图像验证码被广泛应用于各种网站和应用程序,以防止自动化机器人(例如恶意软件)的恶意...
本压缩包包含了一系列与OCR识别验证码相关的文件,包括图像文件、动态链接库(DLL)、源代码和执行程序,以下将对这些文件及相关的知识点进行详细介绍。 首先,我们看到有多个`.bmp`文件,如1.bmp、3.bmp和2.bmp。...