-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyolo-fastestv2.h
55 lines (43 loc) · 1.17 KB
/
yolo-fastestv2.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef NCNN_H_
#define NCNN_H_
#include "net.h"
#include <vector>
#include <opencv2/opencv.hpp>
class TargetBox
{
private:
float getWidth() { return (x2 - x1); };
float getHeight() { return (y2 - y1); };
public:
int x1;
int y1;
int x2;
int y2;
int cate;
float score;
float area() { return getWidth() * getHeight(); };
};
class yoloFastestv2
{
private:
ncnn::Net net;
std::vector<float> anchor;
int numAnchor;
int numOutput;
int numThreads;
int numCategory;
int inputWidth, inputHeight;
float nmsThresh;
int nmsHandle(std::vector<TargetBox> &tmpBoxes, std::vector<TargetBox> &dstBoxes);
int getCategory(const float *values, int index, int &category, float &score);
int predHandle(const ncnn::Mat *out, std::vector<TargetBox> &dstBoxes,
const float scaleW, const float scaleH, const float thresh);
public:
yoloFastestv2();
~yoloFastestv2();
int init(const bool use_vulkan_compute=false);
int loadModel(const char* paramPath, const char* binPath);
int detection(const cv::Mat srcImg, std::vector<TargetBox> &dstBoxes,
const float thresh = 0.3);
};
#endif