added gitingore
This commit is contained in:
@@ -6,6 +6,8 @@ import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
|
||||
/**
|
||||
@@ -16,19 +18,19 @@ public class Main {
|
||||
public static void main(String [ ] args) {
|
||||
File folder = new File("/home/toni/Documents/programme/dirigent/measurements/wearR");
|
||||
File[] listOfFiles = folder.listFiles();
|
||||
/*
|
||||
|
||||
Utils.ShowPNG windowRaw = new Utils.ShowPNG();
|
||||
Utils.ShowPNG windowAuto = new Utils.ShowPNG();
|
||||
Utils.ShowPNG windowPeaksX = new Utils.ShowPNG();
|
||||
Utils.ShowPNG windowPeaksY = new Utils.ShowPNG();
|
||||
Utils.ShowPNG windowPeaksZ = new Utils.ShowPNG();
|
||||
*/
|
||||
|
||||
|
||||
// iterate trough files in measurements folder
|
||||
for (File file : listOfFiles) {
|
||||
if (file.isFile() && file.getName().contains(".csv")) {
|
||||
|
||||
AccelerometerWindowBuffer accWindowBuffer = new AccelerometerWindowBuffer(4096, 256);
|
||||
AccelerometerWindowBuffer accWindowBuffer = new AccelerometerWindowBuffer(1024, 256);
|
||||
BpmEstimator bpmEstimator = new BpmEstimator(accWindowBuffer, 0, 5000);
|
||||
|
||||
//read the file line by line
|
||||
@@ -51,9 +53,9 @@ public class Main {
|
||||
|
||||
double curBpm = bpmEstimator.estimate();
|
||||
//System.out.println("BPM: " + curBpm);
|
||||
/*
|
||||
|
||||
AccelerometerInterpolator acInterp = new AccelerometerInterpolator(accWindowBuffer, bpmEstimator.getSampleRate_ms());
|
||||
|
||||
AccelerometerInterpolator acInterp = new AccelerometerInterpolator(accWindowBuffer, 5);
|
||||
|
||||
//print raw x,y,z
|
||||
double[] dTs = IntStream.range(0, accWindowBuffer.getTs().length).mapToDouble(i -> accWindowBuffer.getTs()[i]).toArray();
|
||||
@@ -68,9 +70,9 @@ public class Main {
|
||||
windowRaw.set(plotRaw.draw());
|
||||
|
||||
//auto corr
|
||||
double[] xAutoCorr = new AutoCorrelation(acInterp.getX(), 1024).getCorr();
|
||||
double[] yAutoCorr = new AutoCorrelation(acInterp.getY(), 1024).getCorr();
|
||||
double[] zAutoCorr = new AutoCorrelation(acInterp.getZ(), 1024).getCorr();
|
||||
double[] xAutoCorr = new AutoCorrelation(acInterp.getX(), 512).getCorr();
|
||||
double[] yAutoCorr = new AutoCorrelation(acInterp.getY(), 512).getCorr();
|
||||
double[] zAutoCorr = new AutoCorrelation(acInterp.getZ(), 512).getCorr();
|
||||
|
||||
//print autocorr
|
||||
int[] tmp = IntStream.rangeClosed(-((xAutoCorr.length - 1)/2), ((xAutoCorr.length - 1)/2)).toArray();
|
||||
@@ -87,7 +89,7 @@ public class Main {
|
||||
Peaks pX = new Peaks(xAutoCorr, 50, 0.1f, 0, false);
|
||||
LinkedList<Integer> peaksX = pX.getPeaksIdx();
|
||||
|
||||
double[] dPeaksXX = IntStream.range(0, peaksX.size()).mapToDouble(i -> (peaksX.get(i) - 1024)).toArray();//peaks.stream().mapToDouble(i->i).toArray();
|
||||
double[] dPeaksXX = IntStream.range(0, peaksX.size()).mapToDouble(i -> (peaksX.get(i) - 512)).toArray();//peaks.stream().mapToDouble(i->i).toArray();
|
||||
double[] dPeaksXY = IntStream.range(0, peaksX.size()).mapToDouble(i -> (xAutoCorr[peaksX.get(i)])).toArray();
|
||||
Plot plotPeaksX = Plot.plot(Plot.plotOpts().
|
||||
title("Peak Detection on X").
|
||||
@@ -101,7 +103,7 @@ public class Main {
|
||||
Peaks pY = new Peaks(yAutoCorr, 50, 0.1f, 0, false);
|
||||
LinkedList<Integer> peaksY = pY.getPeaksIdx();
|
||||
|
||||
double[] dPeaksYX = IntStream.range(0, peaksY.size()).mapToDouble(i -> (peaksY.get(i) - 1024)).toArray();//peaks.stream().mapToDouble(i->i).toArray();
|
||||
double[] dPeaksYX = IntStream.range(0, peaksY.size()).mapToDouble(i -> (peaksY.get(i) - 512)).toArray();//peaks.stream().mapToDouble(i->i).toArray();
|
||||
double[] dPeaksYY = IntStream.range(0, peaksY.size()).mapToDouble(i -> (yAutoCorr[peaksY.get(i)])).toArray();
|
||||
Plot plotPeaksY = Plot.plot(Plot.plotOpts().
|
||||
title("Peak Detection on Y").
|
||||
@@ -115,7 +117,7 @@ public class Main {
|
||||
Peaks pZ = new Peaks(zAutoCorr, 50, 0.1f, 0, false);
|
||||
LinkedList<Integer> peaksZ = pZ.getPeaksIdx();
|
||||
|
||||
double[] dPeaksZX = IntStream.range(0, peaksZ.size()).mapToDouble(i -> (peaksZ.get(i) - 1024)).toArray();//peaks.stream().mapToDouble(i->i).toArray();
|
||||
double[] dPeaksZX = IntStream.range(0, peaksZ.size()).mapToDouble(i -> (peaksZ.get(i) - 512)).toArray();//peaks.stream().mapToDouble(i->i).toArray();
|
||||
double[] dPeaksZY = IntStream.range(0, peaksZ.size()).mapToDouble(i -> (zAutoCorr[peaksZ.get(i)])).toArray();
|
||||
Plot plotPeaksZ = Plot.plot(Plot.plotOpts().
|
||||
title("Peak Detection on Z").
|
||||
@@ -134,7 +136,7 @@ public class Main {
|
||||
//System.out.println("BPM-Z: " + pZ.getBPM(bpmEstimator.getSampleRate_ms()));
|
||||
|
||||
//todo: kleiner fenstergrößen testen. so ist doch etwas langsam auf der Uhr.
|
||||
*/
|
||||
|
||||
int dummyForBreakpoint = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class AccelerometerWindowBuffer extends ArrayList<AccelerometerData> {
|
||||
}
|
||||
|
||||
public boolean isNextWindowReady(){
|
||||
if((size() == mWindowSize || size() == mWindowSize / 2 || size() == mWindowSize / 4) && mOverlapCounter > mOverlapSize){
|
||||
if((size() > mWindowSize / 2) && mOverlapCounter > mOverlapSize){
|
||||
mOverlapCounter = 1;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -77,6 +77,7 @@ public class BpmEstimator {
|
||||
//kalman filter (lohnt dann, wenn wir konstantes tempo haben, mit startangabe!)
|
||||
|
||||
mBpmHistory.add(estimatedBPM);
|
||||
mResetCounter = 0;
|
||||
}
|
||||
else {
|
||||
int resetAfter = (int) Math.round(mResetLimit_ms / (mBuffer.getOverlapSize() * sampleRate));
|
||||
@@ -102,9 +103,9 @@ public class BpmEstimator {
|
||||
private double getBestBpmEstimation(Peaks peaksX, Peaks peaksY, Peaks peaksZ) throws IllegalArgumentException {
|
||||
|
||||
int cntNumAxis = 0;
|
||||
double sumCorr = 1; //to prevent division by zero
|
||||
double sumRms = 1;
|
||||
double sumNumInter = 1;
|
||||
double sumCorr = 0; //to prevent division by zero
|
||||
double sumRms = 0;
|
||||
double sumNumInter = 0;
|
||||
|
||||
double corrMeanX = 0, corrRmsX = 0;
|
||||
int corrNumInterX = 0;
|
||||
@@ -167,7 +168,7 @@ public class BpmEstimator {
|
||||
|
||||
//values to low, reject
|
||||
//TODO: this is a pretty simple assumption. first shot!
|
||||
if(corrRmsX < 0.2 && corrRmsY < 0.2 && corrRmsZ < 0.2){
|
||||
if(corrRmsX < 0.25 && corrRmsY < 0.25 && corrRmsZ < 0.25){
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user