vitis::ai::YOLOvX - 2.5 简体中文

Vitis AI Library 用户指南 (UG1354)

Document ID
UG1354
Release Date
2022-06-15
Version
2.5 简体中文
此基本类用于检测输入图像 (cv::Mat) 中的对象。

输入为图像 (cv::Mat)。

输出是输入图像中行人的位置。

代码样本:

auto yolo = vitis::ai::YOLOvX::create("yolovx_pt", true);

Mat img = cv::imread("sample_yolovx.jpg");
auto results = yolo->run(img);

for (auto& result : results.bboxes) {
  int label = result.label;
  auto& box = result.box;

  cout << "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";
  rectangle(img, Point(box[0], box[1]), Point(box[2], box[3]),
            Scalar(0, 255, 0), 1, 1, 0);
}
imwrite("result.jpg", img);

函数快速参考

下表列出了 vitis::ai::YOLOvX 类中定义的所有函数:

表 1. 函数快速参考
类型 成员 实参
std::unique_ptr< YOLOvX > create
  • const std::string & model_name
  • bool need_preprocess
std::unique_ptr< YOLOvX > create
  • const std::string & model_name
  • xir::Attrs * attrs
  • bool need_preprocess
YOLOvXResult run
  • const cv::Mat & image
std::vector< YOLOvXResult > run
  • const std::vector< cv::Mat > & images