yolo.h
#pragma once
#include
#include<opencv2/opencv.hpp>
//#include
//using namespace std;
//using namespace cv;
//using namespace dnn;
struct Output {
int id;//结果类别id
float confidence;//结果置信度
cv::Rect box;//矩形框
};
class Yolo {
public:
Yolo() {
}
~Yolo() {}
bool readModel(cv::dnn::Net& net, std::string& netPath, bool isCuda);
bool Detect(cv::Mat& SrcImg, cv::dnn::Net& net, std::vector& output);
void drawPred(cv::Mat& img, std::vector result, std::vectorcv::Scalar color);
private:
float Sigmoid(float x) {
return static_cast(1.f / (1.f + exp(-x)));
}
const float netAnchors[3][6] = { { 10.0, 13.0, 16.0, 30.0, 33.0, 23.0 },{ 30.0, 61.0, 62.0, 45.0, 59.0, 119.0 },{ 116.0, 90.0, 156.0, 198.0, 373.0, 326.0 } };
const float netStride[3] = { 8, 16.0,32 };
const int netWidth = 640;
const int netHeight = 640;
float nmsThreshold = 0.45;
float boxThreshold = 0.25;
float classThreshold = 0.25;
std::vectorstd::string className = { “call”, “four”, “like”, “ok”, “one”,“no_gesture”};
//std::vectorstd::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”, “