vitis::ai::RefineDet
Input is an image (cv::Mat).
Output is the position and score of the pedestrians in the input image.
Sample code:
auto det = vitis::ai::RefineDet::create("refinedet_pruned_0_8");
auto image = cv::imread("sample_refinedet.jpg");
cout << "load image" << endl;
if (image.empty()) {
cerr << "cannot load " << argv[1] << endl;
abort();
}
auto results = det->run(image);
auto img = image.clone();
for (auto &box : results.bboxes) {
float x = box.x * (img.cols);
float y = box.y * (img.rows);
int xmin = x;
int ymin = y;
int xmax = x + (box.width) * (img.cols);
int ymax = y + (box.height) * (img.rows);
float score = box.score;
xmin = std::min(std::max(xmin, 0), img.cols);
xmax = std::min(std::max(xmax, 0), img.cols);
ymin = std::min(std::max(ymin, 0), img.rows);
ymax = std::min(std::max(ymax, 0), img.rows);
cv::rectangle(img, cv::Point(xmin, ymin), cv::Point(xmax, ymax),
cv::Scalar(0, 255, 0), 1, 1, 0);
}
auto out = "sample_refinedet_result.jpg";
LOG(INFO) << "write result to " << out;
cv::imwrite(out, img);
Display of the model results:
Quick Function Reference
The following table lists all the functions defined in the vitis::ai::RefineDet
class:
Type | Name | Arguments |
---|---|---|
std::unique_ptr< RefineDet > | create |
|
RefineDetResult | run |
|
std::vector< RefineDetResult > | run |
|
std::vector< vitis::ai::RefineDetResult > | run |
|
create
Factory function to get an instance of derived classes of class RefineDet
.
Prototype
std::unique_ptr< RefineDet
> 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 ofRefineDet
class. run
Function to get running result of the RefineDet
neuron network.
Prototype
RefineDetResult
run(const cv::Mat &image)=0;
Parameters
The following table lists the run
function arguments.
Type | Name | Description |
---|---|---|
const cv::Mat & | image | Input data of input image (cv::Mat). |
Returns
A Struct ofRefineDetResult
. run
Function to get running result of the RefineDet
neuron network in batch mode.
Prototype
std::vector< RefineDetResult
> run(const std::vector< cv::Mat > &images)=0;
Parameters
The following table lists the run
function arguments.
Type | Name | Description |
---|---|---|
const std::vector< cv::Mat > & | images | Input data of input images (vector<cv::Mat>). |
Returns
vector of Struct ofRefineDetResult
. run
Function to get running results of the RefineDet
neuron network in batch mode, used to receive user's xrt_bo to support zero copy.
Prototype
std::vector< vitis::ai::RefineDetResult
> 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. |
Returns
The vector ofRefineDetResult
.