如何将带有字母的图像转换为文本?

时间:2023-02-10 07:25:15

I need to find letters in a image. I need a help to write an algorithm to decode the image.

我需要在图像中找到字母。我需要一个帮助来编写一个算法来解码图像。

I got the image an there is converted in a ByteArrayOutputStream but I don´t know what I do with it.

我得到的图像是在ByteArrayOutputStream中转换的,但我不知道我用它做了什么。

There is my java code:

有我的java代码:

URL url = new URL(urlImg);
WebClient webClient = new WebClient(BrowserVersion.getDefault());
WebRequest reqImg = new WebRequest(url);
reqImg.setHttpMethod(HttpMethod.GET);
InputStream imgStream = webClient.getPage(reqImg).getWebResponse().getContentAsStream();
BufferedImage img = ImageIO.read(imgStream);
ByteArrayOutputStream out = new ByteArrayOutputStream();
ImageIO.write(img, "png", out);

Dependencies: net.sourceforge.htmlunit htmlunit 2.15

依赖关系:net.sourceforge.htmlunit htmlunit 2.15

JDK 1.6.0_43

JDK 1.6.0_43

1 个解决方案

#1


11  

http://scraping.pro/example-captcha-solver-java/

http://scraping.pro/example-captcha-solver-java/

I noticed that you're using Java, this is a way to do it in Java. Decoding Captchas is very possible, assuming the captcha is not very secure. This is exactly why captchas are always getting more complex - people can break them.

我注意到你正在使用Java,这是一种用Java实现的方法。假设验证码不是很安全,解码验证码是非常可能的。这正是验证码总是越来越复杂的原因 - 人们可以打破它们。

Edit If you aren't hard set on Java and don't want to use a paid service, you could use this tutorial with Python: http://www.boyter.org/decoding-captchas/

编辑如果您没有在Java上进行硬设置并且不想使用付费服务,则可以在Python中使用本教程:http://www.boyter.org/decoding-captchas/

-By the way- Decoding Captchas is not always unethical. Sometimes it is required or makes life much easier. For example a company I'm working with will not disable the Captcha on their sites for automated tests that I've made. If I wanted to run my automated tests, I'd have to bypass the Captcha. Granted that also means other people can also bypass the Captcha if they really wanted to, but the company apparently doesn't care and wants easy to read, traditional Captchas.

- 顺便说一句 - 解码验证并不总是不道德的。有时需要它或使生活更轻松。例如,我正在使用的公司不会在他们的网站上禁用Captcha进行自动化测试。如果我想运行自动化测试,我必须绕过Captcha。也许这意味着其他人也可以绕过Captcha,如果他们真的想要,但该公司显然不关心,并希望易于阅读,传统的Captchas。

#1


11  

http://scraping.pro/example-captcha-solver-java/

http://scraping.pro/example-captcha-solver-java/

I noticed that you're using Java, this is a way to do it in Java. Decoding Captchas is very possible, assuming the captcha is not very secure. This is exactly why captchas are always getting more complex - people can break them.

我注意到你正在使用Java,这是一种用Java实现的方法。假设验证码不是很安全,解码验证码是非常可能的。这正是验证码总是越来越复杂的原因 - 人们可以打破它们。

Edit If you aren't hard set on Java and don't want to use a paid service, you could use this tutorial with Python: http://www.boyter.org/decoding-captchas/

编辑如果您没有在Java上进行硬设置并且不想使用付费服务,则可以在Python中使用本教程:http://www.boyter.org/decoding-captchas/

-By the way- Decoding Captchas is not always unethical. Sometimes it is required or makes life much easier. For example a company I'm working with will not disable the Captcha on their sites for automated tests that I've made. If I wanted to run my automated tests, I'd have to bypass the Captcha. Granted that also means other people can also bypass the Captcha if they really wanted to, but the company apparently doesn't care and wants easy to read, traditional Captchas.

- 顺便说一句 - 解码验证并不总是不道德的。有时需要它或使生活更轻松。例如,我正在使用的公司不会在他们的网站上禁用Captcha进行自动化测试。如果我想运行自动化测试,我必须绕过Captcha。也许这意味着其他人也可以绕过Captcha,如果他们真的想要,但该公司显然不关心,并希望易于阅读,传统的Captchas。