-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathcar_benchmark.hpp
47 lines (36 loc) · 1.19 KB
/
car_benchmark.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
#ifndef CAR_BENCHMARK_H
#define CAR_BENCHMARK_H
#include <opencv2/core.hpp>
#include <tiny_cnn/tiny_cnn.h>
#include <map>
#include <vector>
class car_benchmark
{
public:
car_benchmark();
std::vector<std::pair<double, int>>
predict(cv::Mat const &input);
void train();
private:
using Network = tiny_cnn::network<tiny_cnn::mse, tiny_cnn::adagrad>;
using Imgs = std::vector<tiny_cnn::vec_t>;
using Labels = std::vector<tiny_cnn::label_t>;
void add_data(tiny_cnn::label_t label, cv::Mat const &img,
bool augment, Labels &labels, Imgs &imgs);
void load_car_data(std::string const &folder,
std::map<std::string, cv::Rect> const &car_region,
bool augment, Imgs &imgs, Labels &labels);
std::map<std::string, cv::Rect>
load_car_region(std::string const &file) const;
void load_data(std::string const &folder,
tiny_cnn::label_t label,
bool augment,
Imgs &imgs, Labels &labels);
Network nn_;
Imgs test_images_;
Labels test_labels_;
Imgs train_images_;
Labels train_labels_;
void load_data();
};
#endif // CAR_DETECTION_H