vitis::ai::FaceLandmark
Input a face image (cv::Mat).
Output score, five key points of the face.
Sample code:
cv:Mat image = cv::imread("sample_facelandmark.jpg");
auto landmark = vitis::ai::FaceLandmark::create("face_landmark");
auto result = landmark->run(image);
float score = result.score;
auto points = result.points;
for(int i = 0; i< 5 ; ++i){
auto x = points[i].frist * image.cols;
auto y = points[i].second * image.rows;
}
Display of the model results:
Quick Function Reference
The following table lists all the functions defined in the vitis::ai::FaceLandmark
class:
Type | Name | Arguments |
---|---|---|
std::unique_ptr< FaceLandmark > | create |
|
std::unique_ptr< FaceLandmark > | create |
|
int | getInputWidth |
|
int | getInputHeight |
|
size_t | get_input_batch |
|
FaceLandmarkResult | run |
|
std::vector< FaceLandmarkResult > | run |
|
create
Factory function to get an instance of derived classes of class FaceLandmark
.
Prototype
std::unique_ptr< FaceLandmark
> create(const std::string &model_name, bool need_preprocess=true);
Parameters
The following table lists the create
function arguments.
Type | Name | Description |
---|---|---|
const std::string & | model_name | Model name |
bool | need_preprocess | Normalize with mean/scale or not, default value is true. |
Returns
An instance ofFaceLandmark
class. create
Prototype
std::unique_ptr< FaceLandmark
> create(const std::string &model_name, xir::Attrs *attrs, bool need_preprocess=true);
getInputWidth
Function to get InputWidth of the landmark network (input image columns).
Prototype
int getInputWidth() const =0;
Returns
InputWidth of the face landmark network.getInputHeight
Function to get InputHeight of the landmark network (input image rows).
Prototype
int getInputHeight() const =0;
Returns
InputHeight of the face landmark network.get_input_batch
Function to get the number of images processed by the DPU at one time.
Prototype
size_t get_input_batch() const =0;
Returns
Batch size.run
Function to get running result of the face landmark network.
Set data of a face(e.g. data of cv::Mat) and get the five key points.
Prototype
FaceLandmarkResult
run(const cv::Mat &input_image)=0;
Parameters
The following table lists the run
function arguments.
Type | Name | Description |
---|---|---|
const cv::Mat & | input_image | Input data of input image (cv::Mat) of detected by the facedetect network and resized as inputwidth and inputheight. |
Returns
The struct ofFaceLandmarkResult
run
Function to get running results of the face landmark neuron network in batch mode.
Prototype
std::vector< FaceLandmarkResult
> run(const std::vector< cv::Mat > &input_images)=0;
Parameters
The following table lists the run
function arguments.
Type | Name | Description |
---|---|---|
const std::vector< cv::Mat > & | input_images | Input data of input images (std:vector<cv::Mat>). The size of input images equals batch size obtained by get_input_batch. The input images need to be resized to InputWidth and InputHeight required by the network. |
Returns
The vector ofFaceLandmarkResult
.