Skip to content
This repository
tree: 15060b29b6
Fetching contributors…

Cannot retrieve contributors at this time

executable file 52 lines (42 sloc) 1.095 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
#include "Expression.h"

using namespace cv;

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 Mat& sample) {
samples.push_back(sample.clone());
}

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 {
FileStorage fs(ofToDataPath(filename), FileStorage::WRITE);
fs << "description" << description <<
"samples" << "[";
for(int i = 0; i < size(); i++) {
fs << samples[i];
}
fs << "]";
}

void Expression::load(string filename) {
FileStorage fs(ofToDataPath(filename), FileStorage::READ);
description = (string) fs["description"];
FileNode samplesNode = fs["samples"];
int n = samplesNode.size();
samples.resize(n);
for(int i = 0; i < n; i++) {
samplesNode[i] >> samples[i];
}
}
Something went wrong with that request. Please try again.