vitis::ai::YOLOv8 - 3.5 日本語

Vitis AI ライブラリ ユーザー ガイド (UG1354)

Document ID
UG1354
Release Date
2023-06-29
Version
3.5 日本語
入力イメージ (cv::Mat) 内の物体を検出するためのベース クラス。

入力はイメージ (cv::Mat) です。

出力は入力イメージ内の歩行者の位置です。

サンプル コード:

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);
}

関数クイック リファレンス

次の表に、vitis::ai::YOLOv8 クラスに定義されているすべての関数を示します。

表 1. 関数クイック リファレンス
タイプ メンバー 引数
std::unique_ptr< YOLOv8 > create
  • const std::string & model_name
  • bool need_preprocess
std::unique_ptr< YOLOv8 > create
  • const std::string & model_name
  • xir::Attrs * attrs
  • bool need_preprocess
YOLOv8Result run
  • const cv::Mat & image
std::vector< YOLOv8Result > run
  • const std::vector< cv::Mat > & images