21 #ifndef _CLASSIFIER_UTILS_H
22 #define _CLASSIFIER_UTILS_H
39 template<
class Classifier>
40 void load_classifier(
const char *network_file, Classifier & dst,
unsigned int & width,
unsigned int & height,
char* strconf);
49 template<
class Classifier>
50 void load_classifier(
const char *network_file, Classifier & dst,
unsigned int & width,
unsigned int & height);
57 template<
class Classifier>
58 void save_classifier(
const char *network_file,
const Classifier & src,
unsigned int width,
unsigned int height,
const char* config);
63 template<
class Classifier>
64 void load_classifier(
const char *network_file, Classifier & dst,
unsigned int & width,
unsigned int & height)
66 std::ifstream in(network_file);
69 std::string signature;
70 in >> signature >> width >> height;
71 if(signature != dst.signature())
73 std::cerr <<
"expected " << dst.signature() <<
". Readed " << signature << std::endl;
74 throw std::runtime_error(
"wrong signature");
80 std::cerr << network_file <<
" not valid" << std::endl;
81 throw std::runtime_error(
"file not valid");
85 template<
class Classifier>
86 void load_classifier(
const char *network_file, Classifier & dst,
unsigned int & width,
unsigned int & height,
char* strconf)
88 std::ifstream in(network_file);
91 std::string signature;
92 in >> signature >> width >> height;
93 if(signature != dst.signature())
95 std::cerr <<
"expected " << dst.signature() <<
". Readed " << signature << std::endl;
96 throw std::runtime_error(
"wrong signature");
102 std::cerr << network_file <<
" not valid" << std::endl;
103 throw std::runtime_error(
"file not valid");
108 template<
class Classifier>
109 void save_classifier(
const char *network_file,
const Classifier & src,
unsigned int width,
unsigned int height,
const char* config)
111 std::ofstream out(network_file);
113 out << src.signature() <<
' ' << width <<
' ' << height <<
' ' << config <<
'\n' << src;
115 out << src.signature() <<
' ' << width <<
' ' << height <<
'\n' << src;
void save_classifier(const char *network_file, const Classifier &src, unsigned int width, unsigned int height, const char *config)
Definition: Utils.h:109
void load_classifier(const char *network_file, Classifier &dst, unsigned int &width, unsigned int &height, char *strconf)
Definition: Utils.h:86