yolov8.h 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. #pragma once
  2. #include<iostream>
  3. #include<opencv2/opencv.hpp>
  4. #include "yolov8_utils.h"
  5. class Yolov8 {
  6. public:
  7. Yolov8() {
  8. }
  9. ~Yolov8() {}
  10. bool ReadModel(cv::dnn::Net& net, std::string& netPath, bool isCuda);
  11. bool Detect(cv::Mat& srcImg, cv::dnn::Net& net, std::vector<OutputParams>& output);
  12. int _netWidth = 640; //ONNX图片输入宽度
  13. int _netHeight = 640; //ONNX图片输入高度
  14. //类别名,自己的模型需要修改此项
  15. std::vector<std::string> _className = { "person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck", "boat", "traffic light",
  16. "fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow",
  17. "elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee",
  18. "skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove", "skateboard", "surfboard",
  19. "tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple",
  20. "sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "couch",
  21. "potted plant", "bed", "dining table", "toilet", "tv", "laptop", "mouse", "remote", "keyboard", "cell phone",
  22. "microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors", "teddy bear",
  23. "hair drier", "toothbrush" };
  24. private:
  25. float _classThreshold = 0.25;
  26. float _nmsThreshold = 0.45;
  27. };