-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClassificate.hpp
More file actions
118 lines (94 loc) · 3.46 KB
/
Classificate.hpp
File metadata and controls
118 lines (94 loc) · 3.46 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#ifndef CLASSIFICATE_HPP_
#define CLASSIFICATE_HPP_
#define CGAL_LINKED_WITH_TBB
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <string>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Classification.h>
#include <CGAL/Point_set_3.h>
#include <CGAL/Point_set_3/IO.h>
#include <CGAL/Real_timer.h>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point;
typedef CGAL::Point_set_3<Point> Point_set;
typedef Kernel::Iso_cuboid_3 Iso_cuboid_3;
typedef Point_set::Point_map Pmap;
typedef Point_set::Property_map<int> Imap;
namespace Classification = CGAL::Classification;
typedef Classification::Label_handle Label_handle;
typedef Classification::Feature_handle Feature_handle;
typedef Classification::Label_set Label_set;
typedef Classification::Feature_set Feature_set;
// typedef Classification::Sum_of_weighted_features_classifier Classifier;
typedef Classification::ETHZ::Random_forest_classifier Classifier;
typedef Classification::Point_set_feature_generator<Kernel, Point_set, Pmap> Feature_generator;
namespace ZS {
class Classify {
public:
Classify();
~Classify();
/*
** \brief raw points with label or make label
**
*/
bool set_train_dataset(const std::string &in);
bool set_train_dataset(const Point_set &in_point) {
raw_points_with_label_.clear();
raw_points_with_label_ = in_point;
};
/*
** @TODO the method of label
*/
bool set_train_dataset(const std::vector<std::string> &ins);
bool set_train_dataset(const std::vector<Point_set> &ins);
/*
** \brief the based method to generate features
**
*/
bool generate_features(int nb);
/*
** @TODO nulti method to generate features
**/
/*
** \brief set label
**
**/
bool set_labels();
/*
**
**
*/
void train();
private:
Point_set raw_points_with_label_;
Feature_set features_;
Label_set labels_;
Imap label_map_;
}
bool Classify::set_train_dataset(const std::string &in) {
raw_points_with_label_.clear();
std::ifstream infile (in.c_str(), std::ios::binary);
in >> raw_points_with_label_;
bool lm_found = false;
std::tie (label_map_, lm_found) = pts.property_map<int> ("label");
return true;
};
bool Classify::generate_features(int nb = 5) {
std::size_t number_of_scales = nb;
Feature_generator generator (raw_points_with_label_,
raw_points_with_label_.point_map(),
number_of_scales);
features_.begin_parallel_additions();
generator.generate_point_based_features (features_);
features_.end_parallel_additions();
}
bool Classify::train() {
Classification::ETHZ::Random_forest_classifier classifier (labels_, features_);
classifier.train<CGAL::Parallel_if_available_tag> (raw_points_with_label_.range(label_map_),
800);
}
} // end of namespace zs
#endif