-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathExpression.cpp
executable file
·50 lines (41 loc) · 1.05 KB
/
Expression.cpp
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
#include "Expression.h"
Expression::Expression(string description) {
this->description = description;
}
void Expression::setDescription(string description) {
this->description = description;
}
string Expression::getDescription() const {
return description;
}
void Expression::addSample(const cv::Mat& sample) {
samples.push_back(sample.clone());
}
cv::Mat& Expression::getExample(unsigned int i) {
return samples[i];
}
unsigned int Expression::size() const {
return samples.size();
}
void Expression::reset() {
samples.clear();
}
void Expression::save(string filename) const {
cv::FileStorage fs( filename, cv::FileStorage::WRITE);
fs << "description" << description <<
"samples" << "[";
for(int i = 0; i < size(); i++) {
fs << samples[i];
}
fs << "]";
}
void Expression::load(string filename) {
cv::FileStorage fs( filename, cv::FileStorage::READ);
description = (string) fs["description"];
cv::FileNode samplesNode = fs["samples"];
int n = samplesNode.size();
samples.resize(n);
for(int i = 0; i < n; i++) {
samplesNode[i] >> samples[i];
}
}