Code: Show/Hide if ((R == 255 && G == 204 && B == 255) || // background
(R == 69 && G == 58 && B == 40) || //lines (R < 250 && G > 10 && B > 10)) R = G = B = 255 |
Mine GO BOOM wrote: |
or just get a good programmer. PWNtcha is very private, but works great. Give it a shot, download a captcha picture from your registration and submit it there. They say it is 97% for phpbb. |
kingsofchaos.com wrote: |
Updated CAPTCHAs to deter automatic scripts |
Solo Ace wrote: |
I think the reason I'm keeping the images as bitmaps is obvious. |
Quote: |
Play is segmented into ages, which do not have a set length but so far have lasted for about six months. Age 1 launched in early January of 2003, and Age 2 launched in late August the same year. Age 2 ended February 2004, and was followed by a public beta of Age 3. The full version of Age 3 was launched on July 15, and Age 4 began on February 21, 2005. The fifth age was launched on October 9, 2005. Age 6 began on May 14, 2006. |
SpecShip wrote: |
Well, I have no idea how to put it code-wise, but logic wise, it would seem to me that the key is to query for distance between the dots then lock down on clusters whereas the density is high. |
Code: Show/Hide # Optical Character Recognition --- gocr 0.40
# options are: -l 0 -s 0 -v 7 -c _ -m 0 -d -1 -n 0 captcha-015-015.png # using unicode # popen( pngtopnm captcha-015-015.png ) # PNM P6 x=360 y=220 c=255 head=-1 # db_path= (null) # OTSU: thresholdValue = 0 gmin=0 gmax=255 # scanning boxes 6 # auto dust size = 2 (mX=28,mY=37) # remove dust of size 2 histo=3,0(?=0),0(?=0),... 3 cluster removed # 4 white pixels removed, cs=160 # smooth big chars 7x16 cs=160 ... 122 changes in 3 of 3 # detect barcode , 0 bars, boxes-0=3 # detect pictures, frames, noAlphas, mXmY= 55 73 ... 0 - boxes 3 # averages: mXmY= 55 73 nC= 3 n= 3 # remove boxes on border pictures= 0 rest= 3 boxes?= 3 deleted= 0, within pictures pictures= 0 rest= 3 boxes?= 3 . deleted= 0, pictures= 0 rest= 3 boxes?= 3 # rotation angle (x,y,num) (100352,5120,1) (0,0,0), pass 1 # rotation angle (x,y,num) (100352,5120,1) (0,0,0), pass 2 # detect longest line - at y=0 crosses= 0 my=0 - at crosses= 0 dy=0 # scanning lines # trouble on line 1: # bounds: m1= 46 m2= 11 m3= 104 m4= 104 my= 73 # counts: i1= 1 i2= 1 i3= 0 i4= 2 # all boxes of same high! - lines= 1 # add line infos to boxes ... done # divide vertical glued boxes, numC 3 # searching melted serifs ... 0 cluster corrected, 0 new boxes # glue broken chars ... 0 times glued, remaining boxes 3 # detect dust2, ... 1 + 0 boxes deleted, numC= 2 # check for word pitch ... min=28 max=28 pitch_p=29 # ... no spaces found # step 1: char recognition unknown= 2 picts= 0 boxes= 2, 1 of 2 chars unidentified # debug: unknown= 1 picts= 0 boxes= 2 # step 2: try to compare unknown with known chars - found 0 # step 3: try to divide unknown chars, numC 2 # list shape 0 x= 80 46 d= 68 105 h=1 o=1 dots=0 e000 (?) # list box dots=0 c=(?) ac=(?) mod=(0x00) line=1 m= 0 10 104 114 r= 35 0 # list pattern x= 80 46 d= 68 105 t=1 3 ...................................@@@..............................<- ...............................@@@@@@@@@.@@@@....................... .............................@@@@@@@@@@@@@@@@....................... .........................@@@@@@@@@@@@@@@@@@@@@@@@@.................. ......@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@................. ....@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@................ ....@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@................. ...@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@................ ...@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@................. ....@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.................. .....@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@................... ...........@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.................. ...................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.................. ....................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@................. .......................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@............... .......................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@............... .....................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@............... ......................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@................ ......................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@................. .....................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@................. .....................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@................. ......................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@................. ......................@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@................ .........................@@@@@@@@@@@@@@@@@@@@@@@@@@................. ........................@@@@@@@@@@@@@@@@@@@@@@@@@@@................. ......................@@@@@@@@@@@@@@@@@@@@@@@..@@................... .......................@@@@@@@@@@@@@@@@@@@@@@....................... ..................@@@@@@@@@@@@@@@@@@@@@@@@@@@....................... ......@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.........@...... ......@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.... @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ..@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.. ....@@@......@@@..............@@@@@@@@@@@@@@..........@@@@@@@@@..... # set space width to 29 # insert space between words (dy=115) ... found 0 # step 4: context correction Il1 0O # store boxtree to lines ...get_least_line_indent: page_width 360, dy 0 Line 1, y 46, raw indent 80, adjusted indent 80 Minimum indent is 80 ... 1 lines, boxes= 1, chars= 1 # debug: (_)= 1 picts= 0 chars= 1 (4)=1 Elapsed time: 0:01:19.787. |
Code: Show/Hide # Optical Character Recognition --- gocr 0.40
# options are: -l 0 -s 0 -v 7 -c _ -m 0 -d -1 -n 0 captcha-015-015-sm.png # using unicode # popen( pngtopnm captcha-015-015-sm.png ) # PNM P6 x=90 y=55 c=255 head=-1 # db_path= (null) # OTSU: thresholdValue = 0 gmin=0 gmax=255 # scanning boxes 3 # auto dust size = 1 (mX=13,mY=18) # remove dust of size 1 histo=0,0(?=0),0(?=0),... 0 cluster removed # 0 white pixels removed, cs=160 # smooth big chars 7x16 cs=160 ... 16 changes in 2 of 3 # detect barcode , 0 bars, boxes-0=3 # detect pictures, frames, noAlphas, mXmY= 13 18 ... 0 - boxes 3 # averages: mXmY= 13 18 nC= 3 n= 3 # remove boxes on border pictures= 0 rest= 3 boxes?= 3 deleted= 0, within pictures pictures= 0 rest= 3 boxes?= 3 . deleted= 0, pictures= 0 rest= 3 boxes?= 3 # rotation angle (x,y,num) (25600,1024,1) (0,0,0), pass 1 # rotation angle (x,y,num) (25600,1024,1) (0,0,0), pass 2 # detect longest line - at y=0 crosses= 0 my=0 - at crosses= 0 dy=0 # scanning lines # trouble on line 1: # bounds: m1= 12 m2= 2 m3= 24 m4= 24 my= 18 # counts: i1= 1 i2= 1 i3= 0 i4= 2 # all boxes of same high! - lines= 1 # add line infos to boxes ... done # divide vertical glued boxes, numC 3 # searching melted serifs ... 0 cluster corrected, 0 new boxes # glue broken chars ... 0 times glued, remaining boxes 3 # detect dust2, ... 1 + 0 boxes deleted, numC= 2 # check for word pitch ... min=9 max=9 pitch_p=10 # ... min=25 max=25 v=0.000000 mono=1 pitch_m=25 # step 1: char recognition unknown= 2 picts= 0 boxes= 2, 0 of 2 chars unidentified # debug: unknown= 0 picts= 0 boxes= 2 # step 2: try to compare unknown with known chars - found 0 # step 3: try to divide unknown chars, numC 2 # set space width to 25 # insert space between words (dy=28) ... found 0 # step 4: context correction Il1 0O # store boxtree to lines ...get_least_line_indent: page_width 90, dy 0 Line 1, y 12, raw indent 20, adjusted indent 20 Minimum indent is 20 ... 1 lines, boxes= 2, chars= 2 # debug: (_)= 0 picts= 0 chars= 2 (1)=1 (4)=1 Elapsed time: 0:00:42.897. |
Code: Show/Hide # Optical Character Recognition --- gocr 0.40
# options are: -l 0 -s 0 -v 7 -c _ -m 0 -d -1 -n 0 captcha-017-017.png # popen( pngtopnm captcha-017-017.png ) ERROR src\pnm.c L208: sorry, compile with HAVE_POPEN to use pipes |
Code: Show/Hide FIBITMAP *image = FreeImage_Load(FIF_PNG, filename, 0);
image = FreeImage_Rescale(image, cols / 4, rows / 4, FILTER_BICUBIC); FreeImage_Save(FIF_BMP, image, "temp.bmp", 0); // this one's just so I can easily SEE the resized image :P FreeImage_Save(FIF_PPM, image, "temp.ppm", 0); FreeImage_Unload(image); |
Code: Show/Hide #include <stdio.h>
#include <stdlib.h> #include <string.h> #include "corona.h" #include "FreeImage.h" #define IMAGE_FORMAT corona::PF_R8G8B8 /* RGB mode - 8 bits each */ #define GetXY(x,y, w) ((x) + ((w) * (y))) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define SQ(a) ((a) * (a)) #define DISTANCE(a, b, c, d) (SQ(a - c) + SQ(b - d)) void savepixels(const char *filename, int width, int height, unsigned char *bitmap) { unsigned char *pixels = new unsigned char[width * height * 3]; unsigned char *p = pixels, *b = bitmap; int col, row; for (row = 0; row < height; row++) for (col = 0; col < width; col++) { *p++ = *b; *p++ = *b; *p++ = *b++; } corona::Image *img = corona::CreateImage(width, height, IMAGE_FORMAT, pixels); corona::SaveImage(filename, corona::FF_AUTODETECT, img); delete img; } int main(int argc, char **argv) { corona::Image *img; unsigned char *pixels; char filename[255], *nl; int threshold = 0; int distance = 0; int pixel; char str[255]; int rows, cols; int row, col; unsigned char *bitmap, *p; unsigned char *outmap; FIBITMAP *image; if (argc > 1) { strncpy(filename, argv[1], sizeof(filename) - 13); filename[sizeof(filename)-13] = 0; if (!strcmpi(filename, "/?") || !strcmpi(filename, "-h") || !strcmpi(filename, "--help")) { printf("captcha <filename> <distance> <threshold>\n"); return 0; } if (argc > 3) { distance = atoi(argv[2]); threshold = atoi(argv[3]); } } else { printf("Enter captcha filename: "); fgets(filename, sizeof(filename) - 13, stdin); nl = strchr(filename, '\n'); if (nl) *nl = 0; } img = corona::OpenImage(filename, IMAGE_FORMAT); if (!img) { printf("Could not open file %s\n", filename); return 1; } pixels = (unsigned char*)img->getPixels(); rows = img->getHeight(); cols = img->getWidth(); bitmap = new unsigned char[rows * cols]; p = bitmap; outmap = new unsigned char[rows * cols]; //convert to grayscale of a single byte for (row = 0; row < rows; row++) for (col = 0; col < cols; col++) { pixel = *pixels++; pixel += *pixels++; pixel += *pixels++; *p++ = pixel / 3; } //free corona loading delete img; while (distance <= 0 || distance >= 1000) { printf("Enter distance to check: "); fgets(str, sizeof(str) - 1, stdin); distance = atoi(str); } while (threshold <= 0 || threshold >= 255) { printf("Enter threshold: "); fgets(str, sizeof(str) - 1, stdin); threshold = atoi(str); } //check our threshold for (row = 0; row < rows; row++) for (col = 0; col < cols; col++) { // if (bitmap[GetXY(col, row, cols)]) { int count = 0; int x, y; int dhalf = distance / 2 + 1; //could optimize here heavily, by only checking inside a circle rather than square + distance for (x = MAX(col - dhalf, 0); x < MIN(col + dhalf, cols); x++) for (y = MAX(row - dhalf, 0); y < MIN(row + dhalf, rows); y++) { if (SQ(distance) > DISTANCE(col, row, x, y) && bitmap[GetXY(x, y, cols)]) count++; } if (count >= threshold) outmap[GetXY(col, row, cols)] = 0; else outmap[GetXY(col, row, cols)] = 255; } // else // outmap[GetXY(col, row, cols)] = 0; } //save output nl = strrchr(filename, '.'); if (!nl) nl = &filename[strlen(filename) - 1]; sprintf(nl, "-%03d-%03d.png", distance, threshold); savepixels(filename, cols, rows, outmap); image = FreeImage_Load(FIF_PNG, filename, 0); image = FreeImage_Rescale(image, cols / 4, rows / 4, FILTER_BICUBIC); FreeImage_Save(FIF_BMP, image, "temp.bmp", 0); // this one's just so I can easily SEE the image :P FreeImage_Save(FIF_PPM, image, "temp.ppm", 0); FreeImage_Unload(image); system("gocr -v 7 -c _ -C \"1234567890ero\" temp.ppm > result.txt 2>&1"); delete bitmap; delete outmap; return 0; } |
Solo Ace wrote: |
Bah, I feel dumb now.
Maybe programming isn't meant for me, or maybe I just need more practice or intelligence. :p Have you compiled the GOCR yourself? [...] Note: I'm using 'ero' in "1234567890ero" because I've seen an image containing "err" once, guess that's a good reason to check for it. |
Code: Show/Hide def decode_captcha(image):
return "6hk" |
Code: Show/Hide captcha = "6hk" |