qr_scan | R Documentation |
qr_scan
reads in an image file or magick image object and first
tries to read it using the C++ engine, which is fast and robust at locating
the alignment patterns. However, it is less robust at decoding. If no codes
can be read, the image and corners are passed to the JS engine, which is
slower but has a higher success rate on cropped images.
qr_scan( image, flop = FALSE, lighten = FALSE, darken = TRUE, plot = FALSE, force_js = FALSE, no_js = FALSE, verbose = interactive() )
image |
A path to a magick-readable file, e.g. jpg or png, or a magick object. |
flop |
Logical. Should the image be mirrored L-R before reading? |
lighten |
Logical. Should under-exposed areas of the image be lightened to increase contrast? Useful for images in shadow. Default |
darken |
Logical. Should over-exposed areas of the image be darkened to increase contrast? Useful for images in bright light. Default |
plot |
Logical. Should the image with any detected codes be shown after reading? (Requires ggplot2) |
force_js |
Logical. Should the JS library run even if the C++ library is able to read the code? |
no_js |
Logical. Never use the JS library, even if no QR codes are decoded. |
verbose |
Logical. Should warnings print for potentially slow operations? |
This function calls qr_scan_cpp
and possibly
qr_scan_js_from_corners
. Each function has a
double-while
loop that progressively pushes mid-brightness pixels to
pure black, and if that fails, progressively pushes mid-brightness pixels to
pure white. This algorithm was developed for identifying QR codes on white
printed sheets in outdoor images, in bright sun with or without shadows. To
speed up scanning, you can use arguments lighten = F, darken = F
which
will skip any thresholding. If you use both lighten = T, darken = T
,
scanning may be quite slow until a decodable QR code is found. In those cases,
a progress bar will attempt to be shown, if you have the progress
package (https://github.com/r-lib/progress) available on your machine.
To BYO algorithm, you can use those two functions as templates. For example,
image_morphology
with (..., morphology = "Open", kernel =
"Square:n")
(varying n
from 2 to 10) may repair corrupted QR blocks.
A list of dataframes, values and points, each with a column id.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.