added recent C++ code
This commit is contained in:
@@ -7,9 +7,11 @@
|
||||
#include "../sensors/SensorReader.h"
|
||||
|
||||
struct ClassifiedPattern {
|
||||
std::string className;
|
||||
std::string className; // the class (practice) this pattenr belongs to
|
||||
std::string fileName; // the file that produced this pattern
|
||||
std::vector<float> pattern;
|
||||
ClassifiedPattern(const std::string& className, const std::vector<float>& pattern) : className(className), pattern(pattern) {;}
|
||||
ClassifiedPattern(const std::string& className, const std::string& fileName, const std::vector<float>& pattern) : className(className), fileName(fileName), pattern(pattern) {;}
|
||||
bool belongsToFile(const std::string& fileName) const {return fileName == this->fileName;}
|
||||
};
|
||||
|
||||
struct ClassifiedFeature {
|
||||
@@ -38,6 +40,11 @@ class Data {
|
||||
|
||||
public:
|
||||
|
||||
/** get ALL data files for each practice */
|
||||
static std::vector<ClassifiedDataFile> getAllDataFiles() {
|
||||
return getDataFiles(99999);
|
||||
}
|
||||
|
||||
/** get X data-files for each class */
|
||||
static std::vector<ClassifiedDataFile> getDataFiles(const int filesPerClass) {
|
||||
|
||||
@@ -74,14 +81,28 @@ public:
|
||||
for (const auto& val : rec.accel.values) {intAccel.add(val.ts, val.val);}
|
||||
intAccel.makeRelative();
|
||||
|
||||
K::Interpolator<uint64_t, SensorGyro> intGyro;
|
||||
for (const auto& val : rec.gyro.values) {intGyro.add(val.ts, val.val);}
|
||||
intGyro.makeRelative();
|
||||
|
||||
K::Interpolator<uint64_t, SensorMagneticField> intMagnet;
|
||||
for (const auto& val : rec.magField.values) {intMagnet.add(val.ts, val.val);}
|
||||
intMagnet.makeRelative();
|
||||
|
||||
// determine the region's size
|
||||
const int regionEnd_ms = intAccel.values.back().key * regionPercent;
|
||||
|
||||
|
||||
|
||||
// construct all sample windows
|
||||
std::vector<std::vector<float>> samples;
|
||||
for (int center = regionStart_ms; center < regionEnd_ms; center += stepSize_ms) {
|
||||
std::vector<float> window = getSampleWindow(intAccel, center, windowSize_ms, stepSize_ms);
|
||||
std::vector<float> window;
|
||||
|
||||
// which sensors to use
|
||||
std::vector<float> wAccel = getSampleWindow(intAccel, center, windowSize_ms, stepSize_ms); window.insert(window.end(), wAccel.begin(), wAccel.end());
|
||||
//std::vector<float> wGyro = getSampleWindow(intGyro, center, windowSize_ms, stepSize_ms); window.insert(window.end(), wGyro.begin(), wGyro.end());
|
||||
//std::vector<float> wMagnet = getSampleWindow(intMagnet, center, windowSize_ms, stepSize_ms); window.insert(window.end(), wMagnet.begin(), wMagnet.end());
|
||||
|
||||
|
||||
samples.push_back(window);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user