public class opencv_face extends opencv_face
Constructor and Description |
---|
opencv_face() |
Modifier and Type | Method and Description |
---|---|
static Facemark |
createFacemarkAAM()
construct an AAM facemark detector
|
static Facemark |
createFacemarkKazemi()
construct a Kazemi facemark detector
|
static Facemark |
createFacemarkLBF()
construct an LBF facemark detector
|
static void |
drawFacemarks(Mat image,
Point2fVector points,
Scalar color)
\brief Utility to draw the detected facial landmark points
|
static boolean |
getFaces(Mat image,
RectVector faces,
CParams params)
\brief Default face detector
This function is mainly utilized by the implementation of a Facemark Algorithm.
|
static boolean |
getFacesHAAR(Mat image,
RectVector faces,
String face_cascade_name) |
static boolean |
loadDatasetList(BytePointer imageList,
BytePointer annotationList,
StringVector images,
StringVector annotations)
\brief A utility to load list of paths to training image and annotation file.
|
static boolean |
loadDatasetList(String imageList,
String annotationList,
StringVector images,
StringVector annotations) |
static boolean |
loadFacePoints(String filename,
Point2fVectorVector points,
float offset)
\brief A utility to load facial landmark information from a given file.
|
static boolean |
loadTrainingData(String imageList,
String groundTruth,
StringVector images,
Point2fVectorVector facePoints,
float offset)
\brief A utility to load facial landmark information from the dataset.
|
static boolean |
loadTrainingData(String filename,
StringVector images,
Point2fVectorVector facePoints,
byte delim,
float offset)
\brief A utility to load facial landmark dataset from a single file.
|
static boolean |
loadTrainingData(StringVector filename,
Point2fVectorVector trainlandmarks,
StringVector trainimages)
\brief This function extracts the data for training from .txt files which contains the corresponding image name and landmarks.
|
map
@Namespace(value="cv::face") @opencv_core.Ptr public static Facemark createFacemarkAAM()
@Namespace(value="cv::face") @opencv_core.Ptr public static Facemark createFacemarkLBF()
@Namespace(value="cv::face") @opencv_core.Ptr public static Facemark createFacemarkKazemi()
@Namespace(value="cv::face") @Cast(value="bool") public static boolean getFaces(@ByVal Mat image, @ByRef RectVector faces, CParams params)
image
- The input image to be processed.faces
- Output of the function which represent region of interest of the detected faces.
Each face is stored in cv::Rect container.params
- detector parameters
Example of usage
std::vector<cv::Rect> faces;
CParams params("haarcascade_frontalface_alt.xml");
cv::face::getFaces(frame, faces, ¶ms);
for(int j=0;j<faces.size();j++){
cv::rectangle(frame, faces[j], cv::Scalar(255,0,255));
}
cv::imshow("detection", frame);
@Namespace(value="cv::face") @Cast(value="bool") public static boolean getFacesHAAR(@ByVal Mat image, @ByRef RectVector faces, @opencv_core.Str String face_cascade_name)
@Namespace(value="cv::face") @Cast(value="bool") public static boolean loadDatasetList(@opencv_core.Str BytePointer imageList, @opencv_core.Str BytePointer annotationList, @ByRef StringVector images, @ByRef StringVector annotations)
imageList
- The specified file contains paths to the training images.annotationList
- The specified file contains paths to the training annotations.images
- The loaded paths of training images.annotations
- The 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);
@Namespace(value="cv::face") @Cast(value="bool") public static boolean loadDatasetList(@opencv_core.Str String imageList, @opencv_core.Str String annotationList, @ByRef StringVector images, @ByRef StringVector annotations)
@Namespace(value="cv::face") @Cast(value="bool") public static boolean loadTrainingData(@opencv_core.Str String filename, @ByRef StringVector images, @ByRef Point2fVectorVector facePoints, @Cast(value="char") byte delim, float offset)
filename
- 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
/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 ...
images
- A vector where each element represent the filename of image in the dataset.
Images are not loaded by default to save the memory.facePoints
- The loaded landmark points for all training data.delim
- Delimiter between each element, the default value is a whitespace.offset
- An offset value to adjust the loaded points.
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);
@Namespace(value="cv::face") @Cast(value="bool") public static boolean loadTrainingData(@opencv_core.Str String imageList, @opencv_core.Str String groundTruth, @ByRef StringVector images, @ByRef Point2fVectorVector facePoints, float offset)
imageList
- A file contains the list of image filenames in the training dataset.groundTruth
- 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
- A vector where each element represent the filename of image in the dataset.
Images are not loaded by default to save the memory.facePoints
- The loaded landmark points for all training data.offset
- An offset value to adjust the loaded points.
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
@Namespace(value="cv::face") @Cast(value="bool") public static boolean loadTrainingData(@ByVal StringVector filename, @ByRef Point2fVectorVector trainlandmarks, @ByRef StringVector trainimages)
filename
- A vector of type cv::String containing name of the .txt files.trainlandmarks
- A vector of type cv::Point2f that would store shape or landmarks of all images.trainimages
- A vector of type cv::String which stores the name of images whose landmarks are tracked@Namespace(value="cv::face") @Cast(value="bool") public static boolean loadFacePoints(@opencv_core.Str String filename, @ByRef Point2fVectorVector points, float offset)
filename
- The filename of file contains the facial landmarks data.points
- The loaded facial landmark points.offset
- An offset value to adjust the loaded 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.@Namespace(value="cv::face") public static void drawFacemarks(@ByVal Mat image, @ByRef Point2fVector points, @ByVal(nullValue="cv::Scalar(255,0,0)") Scalar color)
image
- The input image to be processed.points
- Contains the data of points which will be drawn.color
- The color of points in BGR format represented by cv::Scalar.
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));
}
Copyright © 2020. All rights reserved.