动态手势识别--训练模板方法(三)

DTW类:

public class DTW { List newglist = new ArrayList();// 存放修改过的角速度 float n; int whichMin;//判断abc哪个才是最小的 public float getDistance(List mlist, List slist) { int a=mlist.size(); //获取list的长度 int b=slist.size(); float[][] c = new float[a][b]; //判断是否满足长度限制 if(b>0){ //if(b>0.77*l&&b<1.23*l) //R=30 : x-30 < y < x+30 //i>j-30&&i 0){ if(j<=30) c[i][j] = c[i][j - 1] +temp+5; else c[i][j]=Float.MAX_VALUE; } else if (i > 0) { if (j == 0){ if(i<=30) c[i][j] = temp + c[i - 1][j]+5; else c[i][j]=Float.MAX_VALUE; } else{ if(i>j+30||ib){ min=b; whichMin=1; } else{ min=c; whichMin=2; } } else if(c>min){ min=a; whichMin=0; } else{ min=c; whichMin=2; } return min; } //线性插值方法 public List linearInsert(List acctime,List gyrotime,List alist,List glist){ //如果两个if条件同时存在 if(acctime.get(acctime.size()-1)>gyrotime.get(gyrotime.size()-1)){ for(int q=0;q= gyrotime.get(0)){ for(int w=0;wacctime.get(i)){ if(gyrotime.get(j-1)

ComputeModel类:

public class ComputeModel { //共五组数据,每组五个,取第三组数据 平均长度应该取int吗??? double avglength; public List selectinitialsample(List> sampleCollection){//1 if(sampleCollection.size()!=0){//看看sampleCollection的长度是不是0!!! avglength=(sampleCollection.get(0).size()+sampleCollection.get(1).size()+ sampleCollection.get(2).size()+sampleCollection.get(3).size()+ sampleCollection.get(4).size())/5; double min=Math.abs(sampleCollection.get(0).size()-avglength); List initialsample = sampleCollection.get(0); if(Math.abs(sampleCollection.get(1).size()-avglength) mlist, List slist) { DTW dtw=new DTW(); double l=avglength;//登记样本的平均长度 !!!从gestureRecorder中获取每个样本的长度再取平均值(model中的) int a=mlist.size(); //获取list的长度 int b=slist.size(); float[][] c = new float[a][b]; Coordinate [][] path=new Coordinate [a][b];//存放该点的上一个点的坐标 //判断是否满足长度限制 if(b>0.77*l&&b<1.23*l){//R=30 : x-30 < y < x+30 //i>j-30&&i 0){ if(j<=30){ c[i][j] = c[i][j - 1] +temp+5; path[i][j]=new Coordinate(i,j-1); } else{ c[i][j]=Float.MAX_VALUE; path[i][j]=new Coordinate(i,j-1); } } else if (i > 0) { if (j == 0){ if(i<=30){ c[i][j] = temp + c[i - 1][j]+5; path[i][j]=new Coordinate(i-1,j); } else{ c[i][j]=Float.MAX_VALUE; path[i][j]=new Coordinate(i-1,j); } } else{ if(i>j+30||i expansionORcompression(List sample,List initialsample){//返回类型List Coordinate [][] path=getPath(sample,initialsample);//2 int row=path.length;//行 int column=path[0].length;//列 List route=new ArrayList(); route.add(new Coordinate(row-1,column-1)); Coordinate co=path[row-1][column-1]; while(co.getRow()>=0&&co.getColumn()>=0){//将最小路径倒叙插入route中 route.add(co); co=path[co.getRow()][co.getColumn()]; } int x=route.size()-1; int index=0; for(int i=0;i avgSample(List> sampleCollection,List initialsample){//返回类型List List model=new ArrayList(); for(int i=0;i

你可能感兴趣的:(动态手势识别--训练模板方法(三))