public static Letter[] getLetters(Captcha captcha) throws InterruptedException { BackGroundImageManager bgit = new BackGroundImageManager(captcha); bgit.clearCaptchaAll(); // clearlines(captcha); // clearlines(captcha); toBlack(captcha); fill(captcha, 1, 9); PixelObject[] os = getObjects(captcha); // for (PixelObject pixelObject : os) { // BasicWindow.showImage(pixelObject.toLetter().getImage()); // } captcha.reset(); Letter[] lets = new Letter[os.length]; for (int i = 0; i < lets.length; i++) { lets[i] = os[i].toLetter(); int[] l = lets[i].getLocation(); for (int x = 0; x < lets[i].getWidth(); x++) { for (int y = 0; y < lets[i].getHeight(); y++) { lets[i].grid[x][y] = captcha.getPixelValue(x + l[0] - 1, y + l[1] - 1); } } // blurIt(lets[i], 3); toBlack(lets[i]); lets[i].resizetoHeight(30); // BasicWindow.showImage(lets[i].getImage()); } // // BasicWindow.showImage(captcha.getImage()); return lets; }
private int checkBackground(int x, int y, PixelObject n) { int c = captcha.getPixelValue(x, y); boolean b = isBackground(c); if (!b) { n.add(x, y, c); } return b ? 1 : 0; }