Commit 80db4423 authored by norberfabian's avatar norberfabian
Browse files

Merge branch 'fix'

parents e271f016 78e6df17
build/
config/
dist/
nbproject/
dist/
build.xml
catalog.xml
manifest.mf
\ No newline at end of file
/build/
/config/
/dist/
/nbproject/
/dist/
/build.xml
/catalog.xml
/manifest.mf
/amc59.4/
/src.rar
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
\ No newline at end of file
File added
# AST/ASF file generated using VICON BodyLanguage
# -----------------------------------------------
:version 1.10
:name VICON
:units
mass 1.0
length 0.45
angle deg
:documentation
.ast/.asf automatically generated from VICON data using
VICON BodyBuilder and BodyLanguage model FoxedUp or BRILLIANT.MOD
:root
order TX TY TZ RX RY RZ
axis XYZ
position 0 0 0
orientation 0 0 0
:bonedata
begin
id 1
name lhipjoint
direction 0.566809 -0.746272 0.349008
length 2.486467
axis 0 0 0 XYZ
end
begin
id 2
name lfemur
direction 0.34202 -0.939693 0
length 7.0298533
axis 0 0 20 XYZ
dof rx ry rz
limits (-160.0 20.0)
(-70.0 70.0)
(-60.0 70.0)
end
begin
id 3
name ltibia
direction 0.34202 -0.939693 0
length 7.5665565
axis 0 0 20 XYZ
dof rx
limits (-10.0 170.0)
end
begin
id 4
name lfoot
direction 0.0665746 -0.182912 0.980873
length 2.0319207
axis -90 7.62852e-016 20 XYZ
dof rx rz
limits (-45.0 90.0)
(-70.0 20.0)
end
begin
id 5
name ltoes
direction 1.53601e-011 -4.22058e-011 1
length 1.0248597
axis -90 7.62852e-016 20 XYZ
dof rx
limits (-90.0 20.0)
end
begin
id 6
name rhipjoint
direction -0.550236 -0.756381 0.353735
length 2.4588327
axis 0 0 0 XYZ
end
begin
id 7
name rfemur
direction -0.34202 -0.939693 0
length 7.092786
axis 0 0 -20 XYZ
dof rx ry rz
limits (-160.0 20.0)
(-70.0 70.0)
(-70.0 60.0)
end
begin
id 8
name rtibia
direction -0.34202 -0.939693 0
length 7.521779
axis 0 0 -20 XYZ
dof rx
limits (-10.0 170.0)
end
begin
id 9
name rfoot
direction -0.0683029 -0.187661 0.979856
length 2.0840635
axis -90 -7.62852e-016 -20 XYZ
dof rx rz
limits (-45.0 90.0)
(-20.0 70.0)
end
begin
id 10
name rtoes
direction -1.53528e-011 -4.21968e-011 1
length 1.0457201
axis -90 -7.62852e-016 -20 XYZ
dof rx
limits (-90.0 20.0)
end
begin
id 11
name lowerback
direction 0.013823 0.995423 -0.0945635
length 2.0337632
axis 0 0 0 XYZ
dof rx ry rz
limits (-20.0 45.0)
(-30.0 30.0)
(-30.0 30.0)
end
begin
id 12
name upperback
direction 0.0276657 0.9994 -0.020853
length 2.0335853
axis 0 0 0 XYZ
dof rx ry rz
limits (-20.0 45.0)
(-30.0 30.0)
(-30.0 30.0)
end
begin
id 13
name thorax
direction 0.019782 0.999531 0.0233827
length 2.052965
axis 0 0 0 XYZ
dof rx ry rz
limits (-20.0 45.0)
(-30.0 30.0)
(-30.0 30.0)
end
begin
id 14
name lowerneck
direction -0.0308541 0.994709 0.0979874
length 1.7053784
axis 0 0 0 XYZ
dof rx ry rz
limits (-20.0 45.0)
(-30.0 30.0)
(-30.0 30.0)
end
begin
id 15
name upperneck
direction 0.0588398 0.995804 -0.0700903
length 1.7072247
axis 0 0 0 XYZ
dof rx ry rz
limits (-20.0 45.0)
(-30.0 30.0)
(-30.0 30.0)
end
begin
id 16
name head
direction 0.0209966 0.999159 -0.0352225
length 1.7143868
axis 0 0 0 XYZ
dof rx ry rz
limits (-20.0 45.0)
(-30.0 30.0)
(-30.0 30.0)
end
begin
id 17
name lclavicle
direction 0.938182 0.335073 -0.0868338
length 3.4613798
axis 0 0 0 XYZ
dof ry rz
limits (-20.0 10.0)
(0.0 20.0)
end
begin
id 18
name lhumerus
direction 1 -4.48971e-011 -1.26313e-017
length 5.0736656
axis 180 -30 -90 XYZ
dof rx ry rz
limits (-60.0 90.0)
(-90.0 90.0)
(-90.0 90.0)
end
begin
id 19
name lradius
direction 1 -4.48948e-011 -5.89033e-027
length 3.306365
axis 180 -30 -90 XYZ
dof rx
limits (-10.0 170.0)
end
begin
id 20
name lwrist
direction 1 -4.48977e-011 -1.48983e-026
length 1.653182
axis 9.0955e-015 90 90 XYZ
dof ry
limits (-180.0 0.0)
end
begin
id 21
name lhand
direction 1 -4.49046e-011 -2.98066e-026
length 0.6464882
axis 1.90115e-014 90 90 XYZ
dof rx rz
limits (-90.0 90.0)
(-45.0 45.0)
end
begin
id 22
name lfingers
direction 1 -4.48907e-011 -5.95731e-026
length 0.52121544
axis 3.80223e-014 90 90 XYZ
dof rx
limits (0.0 90.0)
end
begin
id 23
name lthumb
direction 0.707107 -6.34963e-011 0.707107
length 0.748365
axis -90 45 -3.84942e-014 XYZ
dof rx rz
limits (-45.0 45.0)
(-45.0 45.0)
end
begin
id 24
name rclavicle
direction -0.909637 0.398485 -0.11735
length 3.431019
axis 0 0 0 XYZ
dof ry rz
limits (-10.0 20.0)
(-20.0 0.0)
end
begin
id 25
name rhumerus
direction -1 -4.48978e-011 -1.09333e-027
length 5.1241627
axis 180 30 90 XYZ
dof rx ry rz
limits (-90.0 60.0)
(-90.0 90.0)
(-90.0 90.0)
end
begin
id 26
name rradius
direction -1 -4.48953e-011 -7.61841e-027
length 3.3258677
axis 180 30 90 XYZ
dof rx
limits (-10.0 170.0)
end
begin
id 27
name rwrist
direction -1 -4.48977e-011 -1.48983e-026
length 1.6629333
axis 9.0955e-015 -90 -90 XYZ
dof ry
limits (-180.0 0.0)
end
begin
id 28
name rhand
direction -1 -4.49027e-011 -2.98038e-026
length 0.6713095
axis 1.90115e-014 -90 -90 XYZ
dof rx rz
limits (-90.0 90.0)
(-45.0 45.0)
end
begin
id 29
name rfingers
direction -1 -4.48838e-011 -5.95531e-026
length 0.54123974
axis 3.80223e-014 -90 -90 XYZ
dof rx
limits (0.0 90.0)
end
begin
id 30
name rthumb
direction -0.707107 -6.34937e-011 0.707107
length 0.7770802
axis -90 -45 3.84942e-014 XYZ
dof rx rz
limits (-45.0 45.0)
(-45.0 45.0)
end
:hierarchy
begin
root lhipjoint rhipjoint lowerback
lhipjoint lfemur
lfemur ltibia
ltibia lfoot
lfoot ltoes
rhipjoint rfemur
rfemur rtibia
rtibia rfoot
rfoot rtoes
lowerback upperback
upperback thorax
thorax lowerneck lclavicle rclavicle
lowerneck upperneck
upperneck head
lclavicle lhumerus
lhumerus lradius
lradius lwrist
lwrist lhand lthumb
lhand lfingers
rclavicle rhumerus
rhumerus rradius
rradius rwrist
rwrist rhand rthumb
rhand rfingers
end
package algorithms;
import Jama.Matrix;
import java.io.Serializable;
import java.util.List;
import objects.DistanceMatrix;
import objects.Template;
public abstract class Classifier implements Serializable {
private DistanceTemplates distanceTemplates;
private DistanceMatrix distanceMatrix;
private Matrix transformationMatrix;
public Classifier() {
}
public DistanceTemplates getDistanceTemplates() {
return distanceTemplates;
private Decision decision;
public Decision getDecision() {
return decision;
}
public void setDistanceTemplates(DistanceTemplates distanceTemplates) {
this.distanceTemplates = distanceTemplates;
public void setDecision(Decision decision) {
this.decision = decision;
}
public DistanceMatrix getDistanceMatrix() {
return distanceMatrix;
}
public void setDistanceMatrix(DistanceMatrix distanceMatrix) {
this.distanceMatrix = distanceMatrix;
}
public Matrix getTransformationMatrix() {
return transformationMatrix;
}
public void setTransformationMatrix(Matrix transformationMatrix) {
this.transformationMatrix = transformationMatrix;
}
public abstract int classify(Template templateQuery, List<Template> templatesGallery);
public double getDistance(Template template1, Template template2) {
return distanceMatrix == null ? distanceTemplates.getDistance(template1, template2) : distanceMatrix.getDistance(template1, template2);
public String classify(Template template){
return decision.decide(template);
}
}
package algorithms;
import java.util.List;
import objects.Template;
public class Classifier1NN extends Classifier {
@Override
public int classify(Template templateQuery, List<Template> templatesGallery) {
Template closestTemplate = new Template(0, "", null);
double minDistance = Double.MAX_VALUE;
for (Template template : templatesGallery) {
double distance = getDistance(template, templateQuery);
if (minDistance > distance) {
minDistance = distance;
closestTemplate = template;
}
}
return closestTemplate.getSubject();
}
}
package algorithms;
public class Classifier1NNDTWKrzeszowski extends Classifier {
public Classifier1NNDTWKrzeszowski() {
DecisionKNN decision = new DecisionKNN();
decision.setK(1);
DistanceTemplatesDTW distanceTemplates = new DistanceTemplatesDTW();
distanceTemplates.setDistancePoses(new DistancePosesKrzeszowski());
decision.setDistanceTemplates(distanceTemplates);
setDecision(decision);
}
public final class DistancePosesKrzeszowski extends DistancePoses {
@Override
public double getDistance(double[] pose1, double[] pose2) {
double w1 = 57.3;
double w2 = 1.7;
int length = pose1.length;
if (pose2.length != length) {
System.out.println("wrong dimensions");
}
double rho = 0;
int d = 0;
while (d < length - 2) {
double sumAngles = 0;
for (int i = 0; i < 3; i++) {
sumAngles += Math.pow(180 - Math.abs(Math.abs(pose1[d + i] - pose2[d + i]) - 180), 2);
d++;
}
rho += Math.sqrt(sumAngles);
}
double heightAndAnkleDistanceDifference = 0;
while (d < length) {
heightAndAnkleDistanceDifference += Math.abs(pose1[d] - pose2[d]);
d++;
}
return w1 * rho + w2 * heightAndAnkleDistanceDifference;
}
}
}
package algorithms;
public class Classifier1NNDTWL1 extends Classifier {
public Classifier1NNDTWL1() {
DecisionKNN decision = new DecisionKNN();
decision.setK(1);
DistanceTemplatesDTW distanceTemplates = new DistanceTemplatesDTW();
distanceTemplates.setDistancePoses(new DistancePosesL1());
decision.setDistanceTemplates(distanceTemplates);
setDecision(decision);
}
}
package algorithms;
public class Classifier1NNDTWL2 extends Classifier {
public Classifier1NNDTWL2() {
DecisionKNN decision = new DecisionKNN();
decision.setK(1);
DistanceTemplatesDTW distanceTemplates = new DistanceTemplatesDTW();
distanceTemplates.setDistancePoses(new DistancePosesL2());
decision.setDistanceTemplates(distanceTemplates);
setDecision(decision);
}
}
package methods;
package algorithms;
import Jama.EigenvalueDecomposition;
import Jama.Matrix;
import algorithms.Classifier1NN;
import algorithms.DistanceTemplates;
import executor.Executor;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import objects.Feature;
import objects.Motion;
import objects.Parameter;
import objects.Template;
public class MethodKumar extends Method {
public class Classifier1NNKumar extends Classifier {
private static final int length = 150; //?
public MethodKumar() {
}
@Override
public Motion loadMotion(File fileAMC) throws IOException {
return Executor.loadMotionJointCoordinates(fileAMC);
}
@Override
public void learnClassifier(List<Motion> motionsLearning) {
Classifier1NN classifier = new Classifier1NN();
DistanceTemplatesKumar distanceTemplates = new DistanceTemplatesKumar();
distanceTemplates.setMeanMatrix(getMeanMatrix(extractTemplates(motionsLearning)));
classifier.setDistanceTemplates(distanceTemplates);
setClassifier(classifier);
}
@Override
public List<Feature> extractFeatures(Motion motion) {
motion.adjust(length);
double[][] data = getVectorJointCoordinates(motion).getArray();
double[] vector = new double[data.length];
for (int i = 0; i < data.length; i++) {
vector[i] = data[i][0];
}
Matrix matrix = new Matrix(vector, getAxes().length * length);
List<Feature> features = new ArrayList();
for (int r = 0; r < matrix.getRowDimension(); r++) {
Parameter[] parameters = new Parameter[matrix.getColumnDimension()];
for (int c = 0; c < matrix.getColumnDimension(); c++) {
parameters[c] = new Parameter(String.valueOf(c), matrix.get(r, c));
}
features.add(new Feature(parameters));
}
return features;
public Classifier1NNKumar() {
DecisionKNN decision = new DecisionKNN();
decision.setK(1);
decision.setDistanceTemplates(new DistanceTemplatesKumar());
setDecision(decision);
}
public final class DistanceTemplatesKumar extends DistanceTemplates {
Matrix meanMatrix;
public DistanceTemplatesKumar() {
}