Description Usage Arguments Value Examples
Plot functionality for bounding boxes detected with image_detect_faces
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
x |
object of class |
image |
object of class |
border |
color of the border of the box. Defaults to red. Passed on to |
lwd |
line width of the border of the box. Defaults to 5. Passed on to |
only_box |
logical indicating to draw only the box and not the text on top of it. Defaults to FALSE. |
col |
color of the text on the box. Defaults to red. Passed on to |
cex |
character expension factor of the text on the box. Defaults to 2. Passed on to |
landmarks |
logical indicating to plot the landmarks as points. Defaults to FALSE. |
col_landmarks |
color of the point of the landmarks. Defaults to black. |
cex_landmarks |
cex of the point of the landmarks. Defaults to 1. |
pch_landmarks |
pch of the point of the landmarks. Defaults to 20. |
... |
other parameters passed on to |
an object of class magick-image
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | library(magick)
path <- system.file(package="image.libfacedetection", "images", "handshake.jpg")
x <- image_read(path)
x
faces <- image_detect_faces(x)
faces
plot(faces, x, border = "red", lwd = 7, col = "white")
plot(faces, x, border = "red", lwd = 7, col = "white", landmarks = TRUE,
col_landmarks = "purple", cex_landmarks = 2, pch_landmarks = 4)
## show one detected face
face <- head(faces$detections, 1)
image_crop(x, geometry_area(x = face$x, y = face$y,
width = face$width, height = face$height))
## show all detected faces
boxcontent <- lapply(seq_len(faces$nr), FUN=function(i){
face <- faces$detections[i, ]
image_crop(x, geometry_area(x = face$x, y = face$y,
width = face$width, height = face$height))
})
boxcontent <- do.call(c, boxcontent)
boxcontent
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.