skotz / cbl-js

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

Help with this example please! #49

Closed lvlashnin closed 3 years ago

lvlashnin commented 4 years ago

Don't removed horizontal line by img.removeHorizontalLine(2) example : line

Thank you!

skotz commented 4 years ago

You'll need to crop the image so that the horizontal line touches the leftmost side of the image. See an example here.

lvlashnin commented 4 years ago

image

Sorry, but it isn't works :(

skotz commented 4 years ago

You'll need more examples to build any usable model. From one image I can't tell how distortion, font, location, rotation, character count, noise, and so on changes from one image to another.

lvlashnin commented 4 years ago

1583095358638 1583095354276 1583095349686 1583095344972 1583095339422 1583095333414 1583095321218 Thanks for your time!

skotz commented 4 years ago

Thanks. Since there's no variation between images at all, this one will be easy to get 100% accuracy on. The digits and lines are in the exact same location in every image, meaning you can simply specify the exact location of every digit and not worry about removing the lines.

You'll want to make sure you pick your training samples very carefully so that you get at least one of each digit in each of the four locations (i.e., one image each for 0-9 as the first digit, an image each for 0-9 as the second digit, and so on so that you train on every possible pattern). Once you create your model, don't condense it so that you maintain the exact patters from the original.

var cbl = new CBL({
    preprocess: function(img) {
        img.binarize(200);
    },
    fixed_blob_locations: [
        { x1: 38,  y1: 9,  x2: 38 + 27,  y2: 9 + 37  },
        { x1: 69,  y1: 19, x2: 70 + 25,  y2: 19 + 37 },
        { x1: 97,  y1: 12, x2: 97 + 25,  y2: 12 + 40 },
        { x1: 123, y1: 9,  x2: 123 + 28, y2: 9 + 37  }
    ],
    character_set: "0123456789",
    exact_characters: 4,
    pattern_width: 24,
    pattern_height: 24,
    allow_console_log: true,
    blob_console_debug: true,
    perceptive_colorspace: true,
    blob_debug: "debugSegmented"
});

cbl.train("3059.jpg");
cbl.train("6204.jpg");
cbl.train("7945.jpg");
cbl.train("8064.jpg");
cbl.train("8677.jpg");
cbl.train("9609.jpg");
cbl.train("9993.jpg");

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

image