Base class for detecting position of vehicle, pedestrian, and so on.
Input is an image (cv:Mat).
Output is a struct of detection results, named SSDResult
.
Sample code :
Mat img = cv::imread("sample_ssd.jpg");
auto ssd = vitis::ai::SSD::create
("ssd_traffic_pruned_0_9",true);
auto results = ssd->run(img);
for(const auto &r : results.bboxes){
auto label = r.label;
auto x = r.x * img.cols;
auto y = r.y * img.rows;
auto width = r.width * img.cols;
auto heigth = r.height * img.rows;
auto score = r.score;
std::cout << "RESULT: " << label << "\t" << x << "\t" << y << "\t" <<
width
<< "\t" << height << "\t" << score << std::endl;
}
Display of the model results:
Figure 1. detection result
Quick Function Reference
The following table lists all the functions defined in the vitis::ai::SSD
class:
Type | Name | Arguments |
---|---|---|
std::unique_ptr< SSD > |
create |
|
std::unique_ptr< SSD > |
create |
|
vitis::ai::SSDResult
|
run |
|
std::vector< vitis::ai::SSDResult > |
run |
|
std::vector< vitis::ai::SSDResult > |
run |
|