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 I can resolve this captcha? #38

Open
bearwmceo opened this issue Sep 28, 2019 · 3 comments
Open

How I can resolve this captcha? #38

bearwmceo opened this issue Sep 28, 2019 · 3 comments
Assignees
Labels

Comments

@bearwmceo
Copy link

Hi, I tried to resolve this captcha but without success, I hope someone can help me.
image
image
image
image
image
image

var cbl = new CBL({
            /* Define a method that takes an input CAPTCHA and performs a set of image operations to remove noise. */
            preprocess: function(img) {
                // Each pixel lighter than the grayscale threshold of 220 is turned white and everything darker is turned black.
                img.binarize(220);
                
                
                // Output the work-in-progress image to an element with a specific ID so we can see the effect of our image operations.
                img.debugImage("debugPreprocessed");
                
                // Flood-fill every blob (a grouping of similarly colored pixels) with a unique color. 
                // This is an important last step of the segmentation phase since the segmenter will create a separate character
                // image for each unique color in the image. If all the characters are black then the segmenter will only find one character.
                img.colorRegions(1, true);
                
                // Once again output the image to a div or something so we see the effect of colorization.
                img.debugImage("debugPreprocessed");
            },
            /* The set of characters that could potentially be in this CAPTCHA system. */
            character_set: "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz",
            /* The minimum number of pixels required to call a grouping of similar pixels a blob. Use this to filter out small specks before segmentation. */
            blob_min_pixels: 140,
            /* The maximum number of pixels required to call a grouping of similar pixels a blob. */
            blob_max_pixels: 700,
            /* The width of the extracted blobs. All patterns are normalized to this width. */
            pattern_width: 25,
            /* The height of the extracted blobs. All patterns are normalized to this height. */
            pattern_height: 25,
            /* Enable advanced logging in the browser's console. */
            allow_console_log: true,
            /* Compare the differences between colors using algorithms based on how the human eye perceives color (instead of just an RGB comparison). */
            perceptive_colorspace: true,
            /* The ID of the element to output all work-in-progress images of segmented characters from each image. */
            blob_debug: "debugSegmented"
        });
@skotz
Copy link
Owner

skotz commented Sep 28, 2019

The third parameter of the colorRegions method will help keep letters together when they're made up of separate lines which aren't touching, and the exact_characters setting can be used whenever a CAPTCHA system always has exactly the same number of characters.

These settings seem to work well.

var cbl = new CBL({
    preprocess: function(img) {
        img.debugImage("debugPreprocessed");
        img.binarize(200);
        img.debugImage("debugPreprocessed");
        img.colorRegions(50, true, 3);
        img.debugImage("debugPreprocessed");
    },
    character_set: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
    exact_characters: 5,
    pattern_width: 25,
    pattern_height: 25,
    blob_min_pixels: 10,
    blob_max_pixels: 1000,
    allow_console_log: true,
    blob_console_debug: true,
    perceptive_colorspace: true,
    blob_debug: "debugSegmented"
});

cbl.train("3jrH5.png");
cbl.train("bHaGR.png");
cbl.train("GCXKa.png");
cbl.train("gSBTt.png");
cbl.train("mXTtA.png");
cbl.train("PWRSX.png");

var saveModel = function() {
    cbl.condenseModel();
    cbl.sortModel();
    cbl.visualizeModel("visualizeModel");
    cbl.saveModel();
}

image

@skotz skotz self-assigned this Sep 28, 2019
@skotz skotz added the question label Sep 28, 2019
@bearwmceo
Copy link
Author

Captchas.zip
I tried with this captchas but It's not working always

@skotz
Copy link
Owner

skotz commented Oct 19, 2019

Did you train a model? What's your solver look like? You can check out the quick start for help in getting started.

I ran through the training for the images above and generated this model:

image

You may want to train on more samples or play around with the segmentation settings, but it performs decently.

image

<div class="main">
    <img id="captcha" src="mXTtA.png" />
    <br />
    <input type="text" id="solution">
    <br />
    <a href="javascript: void(0)" id="solve" onclick="solve()" style="display: none">Solve!</a>
</div>
<script>
    var cbl = new CBL({
        preprocess: function(img) {
            img.binarize(200);
            img.colorRegions(50, true, 3);
        },
        /* Load the model we saved during training. */
        model_file: "condensed-30.txt",
        character_set: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
        exact_characters: 5,
        pattern_width: 25,
        pattern_height: 25,
        blob_min_pixels: 10,
        blob_max_pixels: 1000,
        //allow_console_log: true,
        //blob_console_debug: true,
        perceptive_colorspace: true,
        //blob_debug: "debugSegmented",
        /* Define a method that fires immediately after successfully loading a saved model. */
        model_loaded: function() {
            // Don't enable the solve button until the model is loaded.
            document.getElementById('solve').style.display = "block";
        }
    });    
    
    var solve = function() {
        // Using the saved model, attempt to find a solution to a specific image.
        cbl.solve("captcha").done(function (solution) {
            // Upon finding a solution, fill the solution textbox with the answer.
            document.getElementById('solution').value = solution;
        });
    }
</script>

condensed-30.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants