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)
Run the code above in your browser using DataLab