Base class for detecting objects in the input image (cv::Mat).
Input is an image (cv::Mat).
Output is the position of the pedestrians in the input image.
Sample code:
static cv::Scalar getColor(int label) {
return cv::Scalar(label * 2, 255 - label * 2, label + 50);
}
auto yolo = vitis::ai::YOLOv8::create
("yolov8", true);
Mat img = cv::imread("sample_yolov8.jpg");
auto results = yolov8->run(img);
for (const auto& result : results.bboxes) {
int label = result.label;
auto& box = result.box;
LOG_IF(INFO, is_jpeg) << "RESULT: " << label << "\t" << std::fixed
<< std::setprecision(2) << box[0] << "\t" << box[1]
<< "\t" << box[2] << "\t" << box[3] << "\t"
<< std::setprecision(6) << result.score << "\n";
cv::rectangle(image, cv::Point(box[0], box[1]), cv::Point(box[2], box[3]),
getColor(label), 1, 1, 0);
}
Quick Function Reference
The following table lists all the functions defined in the vitis::ai::YOLOv8
class:
Type | Member | Arguments |
---|---|---|
std::unique_ptr<
YOLOv8
> |
create |
|
std::unique_ptr<
YOLOv8
> |
create |
|
YOLOv8Result
|
run |
|
std::vector<
YOLOv8Result
> |
run |
|