vitis::ai::RetinaFace
Input is an image (cv::Mat).
Output is a vector of position and score for faces in the input image.
Sample code:
auto image = cv::imread("sample_retinaface.jpg");
auto network = vitis::ai::RetinaFace::create(
"retinaface",
true);
auto result = network->run(image);
for (auto i = 0u; i < result.bboxes.size(); ++i) {
auto score = result.bboxes[i].score;
auto x = result.bboxes[i].x * image.cols;
auto y = result.bboxes[i].y * image.rows;
auto width = result.bboxes[i].width * image.cols;
auto height = result.bboxes[i].height * image.rows;
auto landmark = results.landmarks[i];
for (auto j = 0; j < 5; ++j) {
auto px = landmark[j].first * image.cols;
auto py = landmark[j].second * image.rows;
}
}
Display of the model results:
Quick Function Reference
The following table lists all the functions defined in the vitis::ai::RetinaFace
class:
Type | Name | Arguments |
---|---|---|
std::unique_ptr< RetinaFace > | create |
|
std::unique_ptr< RetinaFace > | create |
|
RetinaFaceResult | run |
|
std::vector< RetinaFaceResult > | run |
|
std::vector< RetinaFaceResult > | run |
|
create
Factory function to get an instance of derived classes of class RetinaFace
.
Prototype
std::unique_ptr< RetinaFace
> 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 ofRetinaFace
class. create
Prototype
std::unique_ptr< RetinaFace
> create(const std::string &model_name, xir::Attrs *attrs, bool need_preprocess=true);
run
Function to get running result of the retinaface network.
Prototype
RetinaFaceResult
run(const cv::Mat &img)=0;
Parameters
The following table lists the run
function arguments.
Type | Name | Description |
---|---|---|
const cv::Mat & | img | Input Data ,input image (cv::Mat) need to be resized to InputWidth and InputHeight required by the network. |
Returns
The detection result of the face detect network , filtered by score >= det_thresholdrun
Function to get running results of the retinaface neuron network in batch mode.
Prototype
std::vector< RetinaFaceResult
> run(const std::vector< cv::Mat > &imgs)=0;
Parameters
The following table lists the run
function arguments.
Type | Name | Description |
---|---|---|
const std::vector< cv::Mat > & | imgs | 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 ofRetinaFaceResult
. run
Function to get running results of the retina neuron network in batch mode , used to receive user's xrt_bo to support zero copy.
Prototype
std::vector< RetinaFaceResult
> run(const std::vector< vart::xrt_bo_t > &input_bos)=0;
Parameters
The following table lists the run
function arguments.
Type | Name | Description |
---|---|---|
const std::vector< vart::xrt_bo_t > & | input_bos | The vector of vart::xrt_bo_t. |