Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How about this one? #20

Closed
c4shm4st3r opened this issue May 26, 2018 · 7 comments
Closed

How about this one? #20

c4shm4st3r opened this issue May 26, 2018 · 7 comments

Comments

@c4shm4st3r
Copy link

c4shm4st3r commented May 26, 2018

hello, i have a harder challange, how would i use the library to presegment and actually solve this single character captcha?

It is a single number from 1-9

I have a working method but i'd like to do with this method just for curiosity of how to get it working with javascript.

verimage-477749927
verimage-905817473
verimage-427168729

Those images are just a small portion of the big dataset as an example. How would i get rid of the trashy background ?

Thanks in the future

@skotz skotz self-assigned this May 26, 2018
@skotz skotz added the question label May 26, 2018
@skotz
Copy link
Owner

skotz commented May 26, 2018

What you really need here is an erosion filter, but unfortunately I haven't implemented that yet. You can try to get by with repeated blurring and binarization since that'll erode away edges until only the thickest lines (the numbers) are left. It's a hack, but the only other option is to implement more image manipulation methods.

var cbl = new CBL({
    preprocess: function(img) {
        img.blur(5);
        img.debugImage("debugPreprocessed");
        img.binarize(45);
        img.debugImage("debugPreprocessed");
        img.blur(5);
        img.debugImage("debugPreprocessed");
        img.binarize(45);
        img.debugImage("debugPreprocessed");
        img.blur(5);
        img.debugImage("debugPreprocessed");
        img.binarize(45);
        img.debugImage("debugPreprocessed");
        img.blur(5);
        img.debugImage("debugPreprocessed");
        img.binarize(45);
        img.debugImage("debugPreprocessed");
        img.blur(5);
        img.debugImage("debugPreprocessed");
        img.binarize(45);
        img.debugImage("debugPreprocessed");
        img.blur(5);
        img.debugImage("debugPreprocessed");
        img.binarize(45);
        img.debugImage("debugPreprocessed");
        img.blur(5);
        img.debugImage("debugPreprocessed");
        img.binarize(45);
        img.debugImage("debugPreprocessed");
        img.colorRegions(40, true);
        img.debugImage("debugPreprocessed");
    },
    character_set: "0123456789",
    blob_min_pixels: 1000,
    blob_max_pixels: 10000,
    pattern_width: 128,
    pattern_height: 128,
    pattern_maintain_ratio: true,
    allow_console_log: true,
    perceptive_colorspace: true,
    blob_debug: "debugSegmented",
    model_loaded: function() {
        document.getElementById("aSolve").style.display = "inline-block";
    }
});

cbl.train("3.png");
cbl.train("2.png");
cbl.train("1.png");

3
1
2
3 png
4
download

@c4shm4st3r
Copy link
Author

damn, im learning quiet a lot with this library, thanks for the reply, i will play around with it.

@c4shm4st3r
Copy link
Author

just one more question, if the captcha character is not in the dataset, does it still detect similarities?

Imagine this, i have 30 different numbers 3's but the new one comes different from all of those, does it still detect similarities? how about inclinations?

@skotz
Copy link
Owner

skotz commented May 26, 2018

If you train a model on several samples of every possible character (say, 5 of each digit), then new instances of that number (not used during training) should have a high likelihood of being correctly classified. Does that answer the question?

@skotz
Copy link
Owner

skotz commented May 26, 2018

So... I added a convolution filter method, meaning now you can play around with erosion filters (Google "convolution kernels" to find common ones). If you get the latest from master, you can now do this:

var cbl = new CBL({
    preprocess: function(img) {
        img.debugImage("debugPreprocessed");
        img.convolute([ [  1,   1,   1,   1,   1,   1,   1],
						[  1,   1,   1,   1,   1,   1,   1],
						[  1,   1,   1,   1,   1,   1,   1],
						[  1,   1,   1, -48,   1,   1,   1],
						[  1,   1,   1,   1,   1,   1,   1],
						[  1,   1,   1,   1,   1,   1,   1], 
						[  1,   1,   1,   1,   1,   1,   1] ]);
        img.debugImage("debugPreprocessed");
		img.cropRelative(0, 5, 0, 5);
        img.debugImage("debugPreprocessed");
        img.colorRegions(2, true);
        img.debugImage("debugPreprocessed");
    },
    character_set: "0123456789",
    blob_min_pixels: 2000,
    blob_max_pixels: 10000,
    pattern_width: 32,
    pattern_height: 32,
    pattern_maintain_ratio: true,
    allow_console_log: true,
    perceptive_colorspace: true,
    blob_debug: "debugSegmented",
    model_loaded: function() {
        document.getElementById("aSolve").style.display = "inline-block";
    }
});

Which gives really good results, if I do say so myself.

1
2
3

Here's how it segments the three samples you had.

c
b
a

@c4shm4st3r
Copy link
Author

c4shm4st3r commented May 31, 2018

Thanks a lot for the support, im now trying to use a bigger dataset.

I will try, thanks <3 <3

@skotz
Copy link
Owner

skotz commented May 31, 2018

I updated the library itself to add the new convolute command, so you'll need to download the latest version for that last snippet to work.

@skotz skotz closed this as completed Jun 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants