qr_scan_cpp | R Documentation |
This is a wrapper function to call the QR code scanner in the quirc
C++ library. You can call this function on file paths, or preprocess files
and call this function on the resulting magick objects.
qr_scan_cpp( image, flop = F, lighten = F, darken = T, debug = F, verbose = interactive() )
image |
A path to a magick-readable file, e.g. jpg or png, or a magick object. |
flop |
Logical. Should image be mirrored L-R? Some generators produce QR codes like this. |
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 |
debug |
Logical. Should additional metadata about decoded QR patterns be included? e.g. ECC level, version number, etc. |
verbose |
Logical. Should warnings print for potentially slow operations? |
This uses 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 this function as a template. For example,
image_morphology
with (..., morphology = "Open", kernel =
"Square:n")
(varying n
from 2 to 10) may repair corrupted QR blocks.
A list of two dataframes, "values" and "points" describing any found QR codes.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.