vitis::ai::FaceQuality5pt

Base class for evaluating the quality and five key points coordinate of a face image (cv::Mat).

Input is a face image (cv::Mat).

Output is the quality and five key points coordinate of a face in the input image.

Sample code : Display of the FaceQuality5pt model results:

cv:Mat image = cv::imread("sample_facequality5pt.jpg");
auto network =
      vitis::ai::FaceQuality5pt::create("face-quality", true);
auto result = network->run(image);
auto quality = result.score;
auto points = result.points;
for(int i = 0; i< 5 ; ++i){
    auto x = points[i].frist  * image.cols;
    auto y = points[j].second * image.rows;
}
Note: Default mode is day, if day night switch network is used and the background of the input image is night, please use API setMode
network->setMode(vitis::ai::FaceQuality5pt::Mode::NIGHT);
Figure 1: result image

Image sample_facedetect_result.jpg

Quick Function Reference

The following table lists all the functions defined in the vitis::ai::FaceQuality5pt class:

Table 1. Quick Function Reference
TypeNameArguments
std::unique_ptr< FaceQuality5pt >create
  • const std::string & model_name
  • bool need_preprocess
intgetInputWidth
  • void
intgetInputHeight
  • void
size_tget_input_batch
  • void
ModegetMode
  • void
voidsetMode
  • Mode mode
FaceQuality5ptResultrun
  • const cv::Mat & img
std::vector< FaceQuality5ptResult >run
  • const std::vector< cv::Mat > & images

create

Factory function to get an instance of derived classes of class FaceQuality5pt.

Prototype

std::unique_ptr< FaceQuality5pt > create(const std::string &model_name, bool need_preprocess=true);

Parameters

The following table lists the create function arguments.

Table 2. create 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 of FaceQuality5pt class.

getInputWidth

Function to get InputWidth of the facequality5pt network (input image columns).

Prototype

int getInputWidth() const =0;

Returns

InputWidth of the facequality5pt network.

getInputHeight

Function to get InputHeight of the facequality5pt network (input image rows).

Prototype

int getInputHeight() const =0;

Returns

InputHeight of facequality5pt network.

get_input_batch

Function to get the number of images processed by the DPU at one time.

Note: Different DPU core the batch size may be different. This depends on the IP used.

Prototype

size_t get_input_batch() const =0;

Returns

Batch size.

getMode

Function to get Mode.

Prototype


            Mode getMode()=0;

setMode

Function to set Mode.

Prototype

void setMode(Mode mode)=0;

Parameters

The following table lists the setMode function arguments.

Table 3. setMode Arguments
Type Name Description
Mode mode Type::Mode

Returns

mode

run

Function of get running result of the facequality5pt network.

Prototype


            FaceQuality5ptResult run(const cv::Mat &img)=0;

Parameters

The following table lists the run function arguments.

Table 4. run Arguments
Type Name Description
const cv::Mat & img Input data of input image (cv::Mat) of detected counterpart and resized to InputWidth and InputHeight required by the network.

Returns

The result of the facequality5pt network.

run

Function of get running results of the facequality5pt network in batch mode.

Prototype

std::vector< FaceQuality5ptResult > run(const std::vector< cv::Mat > &images)=0;

Parameters

The following table lists the run function arguments.

Table 5. run Arguments
Type Name Description
const std::vector< cv::Mat > & 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 of the FaceQuality5ptResult.

Enumeration Mode

Scene of sending image.
Table 6. Enumeration Mode Values
Value Description
DAY Use DAY when the background of the image is daytime.
NIGHT Use NIGHT when the background of the image is night.