Description Usage Arguments Value Examples
Detect faces in images using using a convolutional neural network available from https://github.com/ShiqiYu/libfacedetection. The function can be used to detect faces of minimal size 10x10 pixels.
1 |
x |
an object of class magick-image with rgb colors. Or an rgb integer array with pixel values in the 0-255 range. |
A list with elements nr and detections.
Element nr indicates the number of faces found.
The data frame detections indicates the locations of these. This data.frame has columns x, y, width and height
as well as a columns called confidence. The values of x and y are the top left of the start of the box. This data frame also has the x and y locations of 5 face landmarks (eyes, nose and mouth ends).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 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", landmarks = TRUE)
##
## You can also directly pass on the RGB array in BGR format
## without the need of having magick
##
tensor <- image_data(x, channels = "rgb")
tensor <- as.integer(tensor)
faces <- image_detect_faces(tensor)
str(faces)
plot(faces, x)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.