Skip to content

Instantly share code, notes, and snippets.

@jeroen
Last active November 10, 2018 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeroen/3700a76d7a4e447fe440abec0ade851d to your computer and use it in GitHub Desktop.
Save jeroen/3700a76d7a4e447fe440abec0ade851d to your computer and use it in GitHub Desktop.
Rating captchas
# 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