Last active
November 10, 2018 13:57
-
-
Save jeroen/3700a76d7a4e447fe440abec0ade851d to your computer and use it in GitHub Desktop.
Rating captchas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install.packages(c("magick", "tesseract")) | |
stopifnot(packageVersion('magick') >= 2.0) | |
stopifnot(packageVersion('tesseract') >= 4.0) | |
# Use in rstudio to see captcha images | |
rate_captcha <- function(n = 10){ | |
success <- rep(NA, n) | |
for(i in seq_len(n)){ | |
repeat{ | |
img <- magick::image_read('https://issues.apache.org/jira/captcha') | |
text <- tesseract::ocr(img) | |
if(nchar(text)) break | |
} | |
print(img) | |
cat("Tesseract guess:", text, "\n") | |
success[i] <- askYesNo("Is this correct?", prompts = c("Yes", "No", "Cancel")) | |
} | |
cat(sprintf("Tesseract Success rate: %d%%\n", mean(success) * 100)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment