Skip to contents

Given the paths to one or more files, reads and converts them into a captcha list that can be used for modeling or prediction. If lab_in_path=TRUE, will take the label for the Captchas from their filenames using _ as the separator.

Usage

read_captcha(files, lab_in_path = FALSE)

Arguments

files

Paths to one or more captcha images

lab_in_path

Whether or not the labels to the captchas are already in the paths to the files (separated by and underscore in the filename)

Value

A list of class captcha. The captcha object is a list with three elements: $img, which contains the image read from the {magick}

package; $lab, which contains the image label (by default, NULL); and $path, which contains the path of the image.

Details

The read_captcha() function reads a character vector of image files and stores them in memory. Behind the scenes, the function uses the {magick} package to deal with the types of files that may appear (JPEG, PNG, among others).

Examples


captcha_file <- system.file("examples/captcha/esaj.png", package = "captcha")
cap <- read_captcha(captcha_file)
cap
#> # A tibble: 1 × 7
#>   format width height colorspace matte filesize density
#>   <chr>  <int>  <int> <chr>      <lgl>    <int> <chr>  
#> 1 PNG      100     50 sRGB       FALSE     3631 72x72