-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathyolov5.h
36 lines (32 loc) · 1.56 KB
/
yolov5.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once
#include<iostream>
#include<opencv2/opencv.hpp>
#include "yolov5_utils.h"
class Yolov5 {
public:
Yolov5() {
}
~Yolov5() {}
/** \brief Read onnx-model
* \param[in] net:onnx-model
* \param[in] netPath:onnx-model path
* \param[in] isCuda:if true,use GPU(neeed build opencv-cuda),else run it on cpu.
*/
bool ReadModel(cv::dnn::Net& net, std::string& netPath, bool isCuda = false);
bool Detect(cv::Mat& SrcImg, cv::dnn::Net& net, std::vector<OutputSeg>& output);
private:
const int _netWidth = 640; //ONNX图片输入宽度
const int _netHeight = 640; //ONNX图片输入高度
float _classThreshold = 0.25;
float _nmsThreshold = 0.45;
public:
std::vector<std::string> _className = { "person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck", "boat", "traffic light",
"fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow",
"elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee",
"skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove", "skateboard", "surfboard",
"tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple",
"sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "couch",
"potted plant", "bed", "dining table", "toilet", "tv", "laptop", "mouse", "remote", "keyboard", "cell phone",
"microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors", "teddy bear",
"hair drier", "toothbrush" };
};