Base class for detecting pedestrians in the input image (cv::Mat).
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:
Figure 1. result image
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 |
|