skotz / cbl-js

JavaScript CAPTCHA solving library
MIT License
155 stars 47 forks source link

Can you help resolve this #42

Open diepthaiphu opened 4 years ago

diepthaiphu commented 4 years ago

Can you help resolve this 1 2 train 1

    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) {
            img.debugImage("debugPreprocessed");
            img.removeGray(10);
            img.debugImage("debugPreprocessed");
            img.blur();
            img.debugImage("debugPreprocessed");
            img.convolute([ [1, 0, 1],
                            [0, 1, 0],
                            [1, 0, 1] ], 1/3);
            img.debugImage("debugPreprocessed");
            img.blur();
            img.debugImage("debugPreprocessed");
            img.binarize(190);
            img.debugImage("debugPreprocessed");
            img.colorRegions(40, true);
            img.debugImage("debugPreprocessed");
        },
        character_set: "0123456789",
        blob_min_pixels: 50,
        blob_max_pixels: 500,
        pattern_width: 20,
        pattern_height: 20,
        allow_console_log: true,
        blob_debug: "debugSegmented"
    });
skotz commented 4 years ago

First of all you need to increase the blob_max_pixels since those characters are pretty large. You may also want to switch to comparing colors in a perceptive colorspace with perceptive_colorspace and remove any image preprocessing that changes the colors to black before the colorRegions (this is because each character is a separate color, which makes it easier to segment later). I've also used a new command called removeLight, so you'll want to get the latest version of the library to use it.

var cbl = new CBL({
    preprocess: function(img) {
        img.debugImage("debugPreprocessed");
        img.removeLight(128);
        img.debugImage("debugPreprocessed");
        img.colorRegions(14, true);
        img.debugImage("debugPreprocessed");
    },
    character_set: "0123456789",
    exact_characters_width: 50,
    exact_characters_play: 2,
    exact_characters: 4,
    blob_min_pixels: 50,
    blob_max_pixels: 100000,
    blob_max_width: 50,
    pattern_width: 20,
    pattern_height: 20,
    allow_console_log: true,
    blob_console_debug: true,
    perceptive_colorspace: true,
    blob_debug: "debugSegmented"
});

cbl.train("3458.jpg");
cbl.train("4273.jpg");

Play around with that and see if it helps.