draw_faces: Draw detected faces

View source: R/draw_faces.R

draw_facesR Documentation

Draw detected faces

Description

Draws the box and a label for each face on its image or video frame, so you can check what detect_faces found: which faces were detected, how they are numbered, and which faces were recognised as the same person. Faces of the same person share a colour. plot() on a detect_faces result does the same.

Usage

draw_faces(faces, labels = NULL, max_images = 20, dir = tempdir(), plot = TRUE)

## S3 method for class 'te_faces'
plot(x, ...)

Arguments

faces

A data frame returned by detect_faces or select_faces, or a subset of its rows.

labels

Text drawn above each box: one per row of faces, or one for all. By default the face number and person ("face 1, p1"), or for a video the track and person ("track 1, p1"). Use "" for boxes only.

max_images

Most images or video frames to draw. When there are more, they are picked evenly from the first to the last.

dir

Directory for the drawn images (PNG files). Default is a temporary directory.

plot

Logical. Show the drawn images in the plot window, or below the cell in a notebook. Default is TRUE.

x

A data frame returned by detect_faces.

...

Passed to draw_faces().

Details

Only images and frames with a face in faces are drawn. The "media" attribute of a detect_faces result lists every image or frame with its number of faces, including those without any.

For a video, the frames are extracted again (as in face_scores), unless detect_faces kept them with save_frames = TRUE.

Value

The paths of the drawn images, invisibly.

See Also

detect_faces, select_faces

Examples

## Not run: 
image <- system.file("extdata", "two-people.jpg", package = "transforEmotion")
faces <- detect_faces(image)
draw_faces(faces)

# A video: a few frames, with each face's track and person
video <- system.file("extdata", "two-people.mp4", package = "transforEmotion")
plot(detect_faces(video, nframes = 20), max_images = 4)

## End(Not run)


transforEmotion documentation built on Oct. 26, 2026, 5:07 p.m.