View Source Evision.Face (Evision v0.1.28)

Link to this section Summary

Types

t()

Type that represents an Face struct.

Functions

createFacemarkAAM

createFacemarkKazemi

createFacemarkLBF

Utility to draw the detected facial landmark points

Utility to draw the detected facial landmark points

Default face detector This function is mainly utilized by the implementation of a Facemark Algorithm. End users are advised to use function Facemark::getFaces which can be manually defined and circumvented to the algorithm by Facemark::setFaceDetector.

Default face detector This function is mainly utilized by the implementation of a Facemark Algorithm. End users are advised to use function Facemark::getFaces which can be manually defined and circumvented to the algorithm by Facemark::setFaceDetector.

A utility to load list of paths to training image and annotation file.

A utility to load facial landmark information from a given file.

A utility to load facial landmark information from a given file.

A utility to load facial landmark dataset from a single file.

Variant 1:

This function extracts the data for training from .txt files which contains the corresponding image name and landmarks. The first file in each file should give the path of the image whose landmarks are being described in the file. Then in the subsequent lines there should be coordinates of the landmarks in the image i.e each line should be of the form x,y where x represents the x coordinate of the landmark and y represents the y coordinate of the landmark.

A utility to load facial landmark information from the dataset.

Link to this section Types

@type t() :: %Evision.Face{ref: reference()}

Type that represents an Face struct.

  • ref. reference()

    The underlying erlang resource variable.

Link to this section Functions

@spec createFacemarkAAM() :: Evision.Face.Facemark.t() | {:error, String.t()}

createFacemarkAAM

Return
  • retval: Evision.Face.Facemark.t()

Python prototype (for reference only):

createFacemarkAAM() -> retval
@spec createFacemarkKazemi() :: Evision.Face.Facemark.t() | {:error, String.t()}

createFacemarkKazemi

Return
  • retval: Evision.Face.Facemark.t()

Python prototype (for reference only):

createFacemarkKazemi() -> retval
@spec createFacemarkLBF() :: Evision.Face.Facemark.t() | {:error, String.t()}

createFacemarkLBF

Return
  • retval: Evision.Face.Facemark.t()

Python prototype (for reference only):

createFacemarkLBF() -> retval
Link to this function

drawFacemarks(image, points)

View Source
@spec drawFacemarks(Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in()) ::
  Evision.Mat.t() | {:error, String.t()}

Utility to draw the detected facial landmark points

Positional Arguments
  • points: Evision.Mat.t().

    Contains the data of points which will be drawn.

Keyword Arguments
  • color: Scalar.

    The color of points in BGR format represented by cv::Scalar.

Return
  • image: Evision.Mat.t().

    The input image to be processed.

Example of usage
std::vector<Rect> faces;
std::vector<std::vector<Point2f> > landmarks;
facemark->getFaces(img, faces);
facemark->fit(img, faces, landmarks);
for(int j=0;j<rects.size();j++){
face::drawFacemarks(frame, landmarks[j], Scalar(0,0,255));
}

Python prototype (for reference only):

drawFacemarks(image, points[, color]) -> image
Link to this function

drawFacemarks(image, points, opts)

View Source
@spec drawFacemarks(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Utility to draw the detected facial landmark points

Positional Arguments
  • points: Evision.Mat.t().

    Contains the data of points which will be drawn.

Keyword Arguments
  • color: Scalar.

    The color of points in BGR format represented by cv::Scalar.

Return
  • image: Evision.Mat.t().

    The input image to be processed.

Example of usage
std::vector<Rect> faces;
std::vector<std::vector<Point2f> > landmarks;
facemark->getFaces(img, faces);
facemark->fit(img, faces, landmarks);
for(int j=0;j<rects.size();j++){
face::drawFacemarks(frame, landmarks[j], Scalar(0,0,255));
}

Python prototype (for reference only):

drawFacemarks(image, points[, color]) -> image
Link to this function

getFacesHAAR(image, face_cascade_name)

View Source
@spec getFacesHAAR(Evision.Mat.maybe_mat_in(), binary()) ::
  Evision.Mat.t() | false | {:error, String.t()}

Default face detector This function is mainly utilized by the implementation of a Facemark Algorithm. End users are advised to use function Facemark::getFaces which can be manually defined and circumvented to the algorithm by Facemark::setFaceDetector.

Positional Arguments
  • image: Evision.Mat.t().

    The input image to be processed.

  • face_cascade_name: String

Return
  • retval: bool

  • faces: Evision.Mat.t().

    Output of the function which represent region of interest of the detected faces. Each face is stored in cv::Rect container.

Example of usage
std::vector<cv::Rect> faces;
CParams params("haarcascade_frontalface_alt.xml");
cv::face::getFaces(frame, faces, &params);
for(int j=0;j<faces.size();j++){
cv::rectangle(frame, faces[j], cv::Scalar(255,0,255));
}
cv::imshow("detection", frame);

Python prototype (for reference only):

getFacesHAAR(image, face_cascade_name[, faces]) -> retval, faces
Link to this function

getFacesHAAR(image, face_cascade_name, opts)

View Source
@spec getFacesHAAR(
  Evision.Mat.maybe_mat_in(),
  binary(),
  [{atom(), term()}, ...] | nil
) ::
  Evision.Mat.t() | false | {:error, String.t()}

Default face detector This function is mainly utilized by the implementation of a Facemark Algorithm. End users are advised to use function Facemark::getFaces which can be manually defined and circumvented to the algorithm by Facemark::setFaceDetector.

Positional Arguments
  • image: Evision.Mat.t().

    The input image to be processed.

  • face_cascade_name: String

Return
  • retval: bool

  • faces: Evision.Mat.t().

    Output of the function which represent region of interest of the detected faces. Each face is stored in cv::Rect container.

Example of usage
std::vector<cv::Rect> faces;
CParams params("haarcascade_frontalface_alt.xml");
cv::face::getFaces(frame, faces, &params);
for(int j=0;j<faces.size();j++){
cv::rectangle(frame, faces[j], cv::Scalar(255,0,255));
}
cv::imshow("detection", frame);

Python prototype (for reference only):

getFacesHAAR(image, face_cascade_name[, faces]) -> retval, faces
Link to this function

loadDatasetList(imageList, annotationList, images, annotations)

View Source
@spec loadDatasetList(binary(), binary(), [binary()], [binary()]) ::
  boolean() | {:error, String.t()}

A utility to load list of paths to training image and annotation file.

Positional Arguments
  • imageList: String.

    The specified file contains paths to the training images.

  • annotationList: String.

    The specified file contains paths to the training annotations.

  • images: [String].

    The loaded paths of training images.

  • annotations: [String].

    The loaded paths of annotation files.

Return
  • retval: bool

Example of usage:

String imageFiles = "images_path.txt";
String ptsFiles = "annotations_path.txt";
std::vector<String> images_train;
std::vector<String> landmarks_train;
loadDatasetList(imageFiles,ptsFiles,images_train,landmarks_train);

Python prototype (for reference only):

loadDatasetList(imageList, annotationList, images, annotations) -> retval
Link to this function

loadFacePoints(filename)

View Source
@spec loadFacePoints(binary()) :: Evision.Mat.t() | false | {:error, String.t()}

A utility to load facial landmark information from a given file.

Positional Arguments
  • filename: String.

    The filename of file contains the facial landmarks data.

Keyword Arguments
  • offset: float.

    An offset value to adjust the loaded points.

Return
  • retval: bool

  • points: Evision.Mat.t().

    The loaded facial landmark points.

Example of usage
std::vector<Point2f> points;
face::loadFacePoints("filename.txt", points, 0.0f);

The annotation file should follow the default format which is

version: 1
n_points:  68
{
212.716603 499.771793
230.232816 566.290071
...
}

where n_points is the number of points considered and each point is represented as its position in x and y.

Python prototype (for reference only):

loadFacePoints(filename[, points[, offset]]) -> retval, points
Link to this function

loadFacePoints(filename, opts)

View Source
@spec loadFacePoints(binary(), [{atom(), term()}, ...] | nil) ::
  Evision.Mat.t() | false | {:error, String.t()}

A utility to load facial landmark information from a given file.

Positional Arguments
  • filename: String.

    The filename of file contains the facial landmarks data.

Keyword Arguments
  • offset: float.

    An offset value to adjust the loaded points.

Return
  • retval: bool

  • points: Evision.Mat.t().

    The loaded facial landmark points.

Example of usage
std::vector<Point2f> points;
face::loadFacePoints("filename.txt", points, 0.0f);

The annotation file should follow the default format which is

version: 1
n_points:  68
{
212.716603 499.771793
230.232816 566.290071
...
}

where n_points is the number of points considered and each point is represented as its position in x and y.

Python prototype (for reference only):

loadFacePoints(filename[, points[, offset]]) -> retval, points
Link to this function

loadTrainingData(filename, images)

View Source
@spec loadTrainingData(binary(), [binary()]) ::
  Evision.Mat.t() | false | {:error, String.t()}

A utility to load facial landmark dataset from a single file.

Positional Arguments
  • filename: String.

    The filename of a file that contains the dataset information. Each line contains the filename of an image followed by pairs of x and y values of facial landmarks points separated by a space. Example

  • images: [String].

    A vector where each element represent the filename of image in the dataset. Images are not loaded by default to save the memory.

Keyword Arguments
  • delim: char.

    Delimiter between each element, the default value is a whitespace.

  • offset: float.

    An offset value to adjust the loaded points.

Return
  • retval: bool

  • facePoints: Evision.Mat.t().

    The loaded landmark points for all training data.

/home/user/ibug/image_003_1.jpg 336.820955 240.864510 334.238298 260.922709 335.266918 ...
/home/user/ibug/image_005_1.jpg 376.158428 230.845712 376.736984 254.924635 383.265403 ...
Example of usage
cv::String imageFiles = "../data/images_train.txt";
cv::String ptsFiles = "../data/points_train.txt";
std::vector<String> images;
std::vector<std::vector<Point2f> > facePoints;
loadTrainingData(imageFiles, ptsFiles, images, facePoints, 0.0f);

Python prototype (for reference only):

loadTrainingData(filename, images[, facePoints[, delim[, offset]]]) -> retval, facePoints
Link to this function

loadTrainingData(filename, images, opts)

View Source
@spec loadTrainingData(binary(), [binary()], [{atom(), term()}, ...] | nil) ::
  Evision.Mat.t() | false | {:error, String.t()}
@spec loadTrainingData([binary()], [[{number(), number()}]], [binary()]) ::
  boolean() | {:error, String.t()}
@spec loadTrainingData(binary(), binary(), [binary()]) ::
  Evision.Mat.t() | false | {:error, String.t()}

Variant 1:

This function extracts the data for training from .txt files which contains the corresponding image name and landmarks. The first file in each file should give the path of the image whose landmarks are being described in the file. Then in the subsequent lines there should be coordinates of the landmarks in the image i.e each line should be of the form x,y where x represents the x coordinate of the landmark and y represents the y coordinate of the landmark.

Positional Arguments
  • filename: [String].

    A vector of type cv::String containing name of the .txt files.

  • trainlandmarks: [[Point2f]].

    A vector of type cv::Point2f that would store shape or landmarks of all images.

  • trainimages: [String].

    A vector of type cv::String which stores the name of images whose landmarks are tracked

Return
  • retval: bool

For reference you can see the files as provided in the

HELEN dataset

@returns A boolean value. It returns true when it reads the data successfully and false otherwise

Python prototype (for reference only):

loadTrainingData(filename, trainlandmarks, trainimages) -> retval

Variant 2:

A utility to load facial landmark information from the dataset.

Positional Arguments
  • imageList: String.

    A file contains the list of image filenames in the training dataset.

  • groundTruth: String.

    A file contains the list of filenames where the landmarks points information are stored. The content in each file should follow the standard format (see face::loadFacePoints).

  • images: [String].

    A vector where each element represent the filename of image in the dataset. Images are not loaded by default to save the memory.

Keyword Arguments
  • offset: float.

    An offset value to adjust the loaded points.

Return
  • retval: bool

  • facePoints: Evision.Mat.t().

    The loaded landmark points for all training data.

Example of usage
cv::String imageFiles = "../data/images_train.txt";
cv::String ptsFiles = "../data/points_train.txt";
std::vector<String> images;
std::vector<std::vector<Point2f> > facePoints;
loadTrainingData(imageFiles, ptsFiles, images, facePoints, 0.0f);

example of content in the images_train.txt

/home/user/ibug/image_003_1.jpg
/home/user/ibug/image_004_1.jpg
/home/user/ibug/image_005_1.jpg
/home/user/ibug/image_006.jpg

example of content in the points_train.txt

/home/user/ibug/image_003_1.pts
/home/user/ibug/image_004_1.pts
/home/user/ibug/image_005_1.pts
/home/user/ibug/image_006.pts

Python prototype (for reference only):

loadTrainingData(imageList, groundTruth, images[, facePoints[, offset]]) -> retval, facePoints

Variant 3:

A utility to load facial landmark dataset from a single file.

Positional Arguments
  • filename: String.

    The filename of a file that contains the dataset information. Each line contains the filename of an image followed by pairs of x and y values of facial landmarks points separated by a space. Example

  • images: [String].

    A vector where each element represent the filename of image in the dataset. Images are not loaded by default to save the memory.

Keyword Arguments
  • delim: char.

    Delimiter between each element, the default value is a whitespace.

  • offset: float.

    An offset value to adjust the loaded points.

Return
  • retval: bool

  • facePoints: Evision.Mat.t().

    The loaded landmark points for all training data.

/home/user/ibug/image_003_1.jpg 336.820955 240.864510 334.238298 260.922709 335.266918 ...
/home/user/ibug/image_005_1.jpg 376.158428 230.845712 376.736984 254.924635 383.265403 ...
Example of usage
cv::String imageFiles = "../data/images_train.txt";
cv::String ptsFiles = "../data/points_train.txt";
std::vector<String> images;
std::vector<std::vector<Point2f> > facePoints;
loadTrainingData(imageFiles, ptsFiles, images, facePoints, 0.0f);

Python prototype (for reference only):

loadTrainingData(filename, images[, facePoints[, delim[, offset]]]) -> retval, facePoints
Link to this function

loadTrainingData(imageList, groundTruth, images, opts)

View Source
@spec loadTrainingData(binary(), binary(), [binary()], [{atom(), term()}, ...] | nil) ::
  Evision.Mat.t() | false | {:error, String.t()}

A utility to load facial landmark information from the dataset.

Positional Arguments
  • imageList: String.

    A file contains the list of image filenames in the training dataset.

  • groundTruth: String.

    A file contains the list of filenames where the landmarks points information are stored. The content in each file should follow the standard format (see face::loadFacePoints).

  • images: [String].

    A vector where each element represent the filename of image in the dataset. Images are not loaded by default to save the memory.

Keyword Arguments
  • offset: float.

    An offset value to adjust the loaded points.

Return
  • retval: bool

  • facePoints: Evision.Mat.t().

    The loaded landmark points for all training data.

Example of usage
cv::String imageFiles = "../data/images_train.txt";
cv::String ptsFiles = "../data/points_train.txt";
std::vector<String> images;
std::vector<std::vector<Point2f> > facePoints;
loadTrainingData(imageFiles, ptsFiles, images, facePoints, 0.0f);

example of content in the images_train.txt

/home/user/ibug/image_003_1.jpg
/home/user/ibug/image_004_1.jpg
/home/user/ibug/image_005_1.jpg
/home/user/ibug/image_006.jpg

example of content in the points_train.txt

/home/user/ibug/image_003_1.pts
/home/user/ibug/image_004_1.pts
/home/user/ibug/image_005_1.pts
/home/user/ibug/image_006.pts

Python prototype (for reference only):

loadTrainingData(imageList, groundTruth, images[, facePoints[, offset]]) -> retval, facePoints