-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathYOLO.hpp
59 lines (44 loc) · 1.13 KB
/
YOLO.hpp
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
56
57
58
59
// Header file for YOLO.cpp
// Created by Hammad Jutt, March 3 2018
#ifndef YOLO_H
#define YOLO_H
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/core/core.hpp>
#include <vector>
#define INPUT_WIDTH 416
#define INPUT_HEIGHT 416
#define GRID_WIDTH 13
#define GRID_HEIGHT 13
#define CELL_SIZE 32
#define BOXES_PER_CELL 5
#define NUM_CLASSES 20
#define FEATURES_PER_CELL (NUM_CLASSES + 5)*BOXES_PER_CELL
#define CONFIDENCE_THRESHOLD 0.03
#define IOU_THRESHOLD 0.5
#define MAX_BOXES 10
struct Box
{
float x;
float y;
float width;
float height;
};
struct Prediction
{
int classIndex;
float score;
Box box;
};
double sigmoid(double x);
int argMax(std::vector<float> in);
bool comparePredictions(Prediction a, Prediction b);
double iou(Box a, Box b);
std::vector<float> softmax(std::vector<float> in);
std::vector<Prediction> filterRedundantBoxes(
std::vector<Prediction> predictions,
float threshold,
uint limit);
void draw_bounds(cv::Mat &cameraFrame, std::vector<Prediction> predictions);
std::vector<Prediction> interpretNetworkOutput(float ***features);
#endif