private Gesture Circle() { var gesture = new Gesture(); var steps = Enumerable.Range(1, 100) .Select(i => 2 * Math.PI * i / 100.0) .Select(i => new AccelerationVector(-Math.Sin(i), -Math.Cos(i), -Math.Sin(i))); foreach (var s in steps) { gesture.add(s); } return gesture; }
/** * Trains the model to a set of motion-sequences, representing * different evaluations of a gesture * * @param trainsequence a vector of gestures */ public void Train(IEnumerable <Gesture> trainsequence) { // summarize all vectors from the different gestures in one // gesture called sum. double maxacc = 0; double minacc = 0; Gesture sum = new Gesture(); foreach (var gesture in trainsequence) { IEnumerable <AccelerationVector> t = gesture.getData(); // add the max and min acceleration, we later get the average maxacc += gesture.getMaxAcceleration(); minacc += gesture.getMinAcceleration(); // transfer every single accelerationevent of each gesture to // the new gesture sum foreach (var accelerationEvent in t) { sum.add(accelerationEvent); } } // get the average and set it to the sum gesture sum.setMaxAndMinAcceleration(maxacc / trainsequence.Count(), minacc / trainsequence.Count()); // train the centeroids of the quantizer with this master gesture sum. this.quantizer.trainCenteroids(sum); // convert gesture vector to a sequence of discrete values var seqs = new List <int[]>(); foreach (var gesture in trainsequence) { seqs.Add(this.quantizer.getObservationSequence(gesture)); } // train the markov model with this derived discrete sequences this.markovmodell.train(seqs); // set the default probability for use with the bayes classifier this.SetDefaultProbability(trainsequence); }
/** * Trains the model to a set of motion-sequences, representing * different evaluations of a gesture * * @param trainsequence a vector of gestures */ public void Train(IEnumerable<Gesture> trainsequence) { // summarize all vectors from the different gestures in one // gesture called sum. double maxacc = 0; double minacc = 0; Gesture sum = new Gesture(); foreach (var gesture in trainsequence) { IEnumerable<AccelerationVector> t = gesture.getData(); // add the max and min acceleration, we later get the average maxacc += gesture.getMaxAcceleration(); minacc += gesture.getMinAcceleration(); // transfer every single accelerationevent of each gesture to // the new gesture sum foreach (var accelerationEvent in t) { sum.add(accelerationEvent); } } // get the average and set it to the sum gesture sum.setMaxAndMinAcceleration(maxacc / trainsequence.Count(), minacc / trainsequence.Count()); // train the centeroids of the quantizer with this master gesture sum. this.quantizer.trainCenteroids(sum); // convert gesture vector to a sequence of discrete values var seqs = new List<int[]>(); foreach (var gesture in trainsequence) { seqs.Add(this.quantizer.getObservationSequence(gesture)); } // train the markov model with this derived discrete sequences this.markovmodell.train(seqs); // set the default probability for use with the bayes classifier this.SetDefaultProbability(trainsequence); }