OpenCV for Unity 2.6.5
Enox Software / Please refer to OpenCV official document ( http://docs.opencv.org/4.10.0/index.html ) for the details of the argument of the method.
Loading...
Searching...
No Matches
OpenCVForUnity.FaceModule.Face Class Reference

Static Public Member Functions

static Facemark createFacemarkAAM ()
 
static Facemark createFacemarkKazemi ()
 
static Facemark createFacemarkLBF ()
 
static void drawFacemarks (Mat image, Mat points)
 Utility to draw the detected facial landmark points.
 
static void drawFacemarks (Mat image, Mat points, in Vec4d color)
 Utility to draw the detected facial landmark points.
 
static void drawFacemarks (Mat image, Mat points, in(double v0, double v1, double v2, double v3) color)
 Utility to draw the detected facial landmark points.
 
static void drawFacemarks (Mat image, Mat points, Scalar color)
 Utility to draw the detected facial landmark points.
 
static bool getFacesHAAR (Mat image, Mat faces, string face_cascade_name)
 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.
 
static bool loadDatasetList (string imageList, string annotationList, List< string > images, List< string > annotations)
 A utility to load list of paths to training image and annotation file.
 
static bool loadFacePoints (string filename, Mat points)
 A utility to load facial landmark information from a given file.
 
static bool loadFacePoints (string filename, Mat points, float offset)
 A utility to load facial landmark information from a given file.
 
static bool loadTrainingData (List< string > filename, List< MatOfPoint2f > trainlandmarks, List< string > trainimages)
 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.
 
static bool loadTrainingData (string filename, List< string > images, Mat facePoints)
 A utility to load facial landmark dataset from a single file.
 
static bool loadTrainingData (string filename, List< string > images, Mat facePoints, char delim)
 A utility to load facial landmark dataset from a single file.
 
static bool loadTrainingData (string filename, List< string > images, Mat facePoints, char delim, float offset)
 A utility to load facial landmark dataset from a single file.
 
static bool loadTrainingData (string imageList, string groundTruth, List< string > images, Mat facePoints)
 A utility to load facial landmark information from the dataset.
 
static bool loadTrainingData (string imageList, string groundTruth, List< string > images, Mat facePoints, float offset)
 A utility to load facial landmark information from the dataset.
 

Member Function Documentation

◆ createFacemarkAAM()

static Facemark OpenCVForUnity.FaceModule.Face.createFacemarkAAM ( )
static

◆ createFacemarkKazemi()

static Facemark OpenCVForUnity.FaceModule.Face.createFacemarkKazemi ( )
static

◆ createFacemarkLBF()

static Facemark OpenCVForUnity.FaceModule.Face.createFacemarkLBF ( )
static

◆ drawFacemarks() [1/4]

static void OpenCVForUnity.FaceModule.Face.drawFacemarks ( Mat image,
Mat points )
static

Utility to draw the detected facial landmark points.

Parameters
imageThe input image to be processed.
pointsContains the data of points which will be drawn.
colorThe color of points in BGR format represented by cv::Scalar.

<B>Example of usage</B>

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));
}
Template class for a 4-element vector derived from Vec.
Definition Scalar_Ex.cs:9

◆ drawFacemarks() [2/4]

static void OpenCVForUnity.FaceModule.Face.drawFacemarks ( Mat image,
Mat points,
in Vec4d color )
static

Utility to draw the detected facial landmark points.

Parameters
imageThe input image to be processed.
pointsContains the data of points which will be drawn.
colorThe color of points in BGR format represented by cv::Scalar.

<B>Example of usage</B>

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));
}

◆ drawFacemarks() [3/4]

static void OpenCVForUnity.FaceModule.Face.drawFacemarks ( Mat image,
Mat points,
in(double v0, double v1, double v2, double v3) color )
static

Utility to draw the detected facial landmark points.

Parameters
imageThe input image to be processed.
pointsContains the data of points which will be drawn.
colorThe color of points in BGR format represented by cv::Scalar.

<B>Example of usage</B>

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));
}

◆ drawFacemarks() [4/4]

static void OpenCVForUnity.FaceModule.Face.drawFacemarks ( Mat image,
Mat points,
Scalar color )
static

Utility to draw the detected facial landmark points.

Parameters
imageThe input image to be processed.
pointsContains the data of points which will be drawn.
colorThe color of points in BGR format represented by cv::Scalar.

<B>Example of usage</B>

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));
}

◆ getFacesHAAR()

static bool OpenCVForUnity.FaceModule.Face.getFacesHAAR ( Mat image,
Mat faces,
string face_cascade_name )
static

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.

Parameters
imageThe input image to be processed.
facesOutput of the function which represent region of interest of the detected faces. Each face is stored in cv::Rect container.
paramsdetector parameters

<B>Example of usage</B>

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

◆ loadDatasetList()

static bool OpenCVForUnity.FaceModule.Face.loadDatasetList ( string imageList,
string annotationList,
List< string > images,
List< string > annotations )
static

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

Parameters
imageListThe specified file contains paths to the training images.
annotationListThe specified file contains paths to the training annotations.
imagesThe loaded paths of training images.
annotationsThe loaded paths of annotation files.

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);
static bool loadDatasetList(string imageList, string annotationList, List< string > images, List< string > annotations)
A utility to load list of paths to training image and annotation file.
Definition Face.cs:130

◆ loadFacePoints() [1/2]

static bool OpenCVForUnity.FaceModule.Face.loadFacePoints ( string filename,
Mat points )
static

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

Parameters
filenameThe filename of file contains the facial landmarks data.
pointsThe loaded facial landmark points.
offsetAn offset value to adjust the loaded points.

<B>Example of usage</B>

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.

◆ loadFacePoints() [2/2]

static bool OpenCVForUnity.FaceModule.Face.loadFacePoints ( string filename,
Mat points,
float offset )
static

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

Parameters
filenameThe filename of file contains the facial landmarks data.
pointsThe loaded facial landmark points.
offsetAn offset value to adjust the loaded points.

<B>Example of usage</B>

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.

◆ loadTrainingData() [1/6]

static bool OpenCVForUnity.FaceModule.Face.loadTrainingData ( List< string > filename,
List< MatOfPoint2f > trainlandmarks,
List< string > trainimages )
static

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.

For reference you can see the files as provided in the <a href="http://www.ifp.illinois.edu/~vuongle2/helen/">HELEN dataset</a>

Parameters
filenameA vector of type cv::String containing name of the .txt files.
trainlandmarksA vector of type cv::Point2f that would store shape or landmarks of all images.
trainimagesA vector of type cv::String which stores the name of images whose landmarks are tracked
Returns
A boolean value. It returns true when it reads the data successfully and false otherwise

◆ loadTrainingData() [2/6]

static bool OpenCVForUnity.FaceModule.Face.loadTrainingData ( string filename,
List< string > images,
Mat facePoints )
static

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

Parameters
filenameThe 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
/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 ...
Parameters
imagesA vector where each element represent the filename of image in the dataset. Images are not loaded by default to save the memory.
facePointsThe loaded landmark points for all training data.
delimDelimiter between each element, the default value is a whitespace.
offsetAn offset value to adjust the loaded points.

<B>Example of usage</B>

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);
static bool loadTrainingData(string filename, List< string > images, Mat facePoints, char delim, float offset)
A utility to load facial landmark dataset from a single file.
Definition Face.cs:181

◆ loadTrainingData() [3/6]

static bool OpenCVForUnity.FaceModule.Face.loadTrainingData ( string filename,
List< string > images,
Mat facePoints,
char delim )
static

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

Parameters
filenameThe 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
/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 ...
Parameters
imagesA vector where each element represent the filename of image in the dataset. Images are not loaded by default to save the memory.
facePointsThe loaded landmark points for all training data.
delimDelimiter between each element, the default value is a whitespace.
offsetAn offset value to adjust the loaded points.

<B>Example of usage</B>

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);

◆ loadTrainingData() [4/6]

static bool OpenCVForUnity.FaceModule.Face.loadTrainingData ( string filename,
List< string > images,
Mat facePoints,
char delim,
float offset )
static

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

Parameters
filenameThe 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
/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 ...
Parameters
imagesA vector where each element represent the filename of image in the dataset. Images are not loaded by default to save the memory.
facePointsThe loaded landmark points for all training data.
delimDelimiter between each element, the default value is a whitespace.
offsetAn offset value to adjust the loaded points.

<B>Example of usage</B>

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);

◆ loadTrainingData() [5/6]

static bool OpenCVForUnity.FaceModule.Face.loadTrainingData ( string imageList,
string groundTruth,
List< string > images,
Mat facePoints )
static

A utility to load facial landmark information from the dataset.

Parameters
imageListA file contains the list of image filenames in the training dataset.
groundTruthA 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).
imagesA vector where each element represent the filename of image in the dataset. Images are not loaded by default to save the memory.
facePointsThe loaded landmark points for all training data.
offsetAn offset value to adjust the loaded points.

<B>Example of usage</B>

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

◆ loadTrainingData() [6/6]

static bool OpenCVForUnity.FaceModule.Face.loadTrainingData ( string imageList,
string groundTruth,
List< string > images,
Mat facePoints,
float offset )
static

A utility to load facial landmark information from the dataset.

Parameters
imageListA file contains the list of image filenames in the training dataset.
groundTruthA 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).
imagesA vector where each element represent the filename of image in the dataset. Images are not loaded by default to save the memory.
facePointsThe loaded landmark points for all training data.
offsetAn offset value to adjust the loaded points.

<B>Example of usage</B>

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

The documentation for this class was generated from the following files: