Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Michal Balážia
GaitRecognition
Commits
f2beb02f
Commit
f2beb02f
authored
Nov 07, 2016
by
Michal Balazia
Browse files
gitignore
parent
6b4584d7
Changes
6
Hide whitespace changes
Inline
Side-by-side
.gitignore
0 → 100644
View file @
f2beb02f
build/
config/
dist/
nbproject/
dist/
build.xml
catalog.xml
\ No newline at end of file
src/executor/Executor.java
View file @
f2beb02f
...
...
@@ -66,7 +66,7 @@ public class Executor {
private
static
final
boolean
extractDatabase
=
false
;
private
static
final
boolean
learnClassifiers
=
false
;
private
static
final
boolean
performClassifications
=
false
;
private
static
final
boolean
evaluateMethods
=
fals
e
;
private
static
final
boolean
evaluateMethods
=
tru
e
;
/*
Select evaluation set-ups at evaluateMethods()
...
...
@@ -78,23 +78,23 @@ public class Executor {
All implemented MoCap-based gait recognition methods
*/
private
static
final
Method
[]
methods
=
new
Method
[]{
new
MethodAhmed
(),
//0
new
MethodAli
(),
//1
new
MethodAndersson
(),
//2
new
MethodBall
(),
//3
new
MethodDikovski
(),
//4
//
new MethodAhmed(),//0
//
new MethodAli(),//1
//
new MethodAndersson(),//2
//
new MethodBall(),//3
//
new MethodDikovski(),//4
new
MethodGavrilova
(),
//5
new
MethodJiang
(),
//6
new
MethodKrzeszowski
(),
//7
new
MethodKumar
(),
//8
new
MethodKwolek
(),
//9
new
MethodPreis
(),
//10
new
MethodSedmidubsky
(),
//11
new
MethodSinha
(),
//12
new
Method_MMC
(),
//13
new
Method_PCALDA
(),
//14
new
Method_Random
(),
//15
new
Method_Raw
(),
//16
//
new MethodJiang(),//6
//
new MethodKrzeszowski(),//7
//
new MethodKumar(),//8
//
new MethodKwolek(),//9
//
new MethodPreis(),//10
//
new MethodSedmidubsky(),//11
//
new MethodSinha(),//12
//
new Method_MMC(),//13
//
new Method_PCALDA(),//14
//
new Method_Random(),//15
//
new Method_Raw(),//16
};
/*
...
...
@@ -395,16 +395,16 @@ public class Executor {
public
static
String
printTime
(
double
time
)
{
String
unit
=
"ms"
;
if
(
time
>
1000
)
{
if
(
time
>
=
1000
)
{
time
/=
1000
;
unit
=
"s"
;
if
(
time
>
60
)
{
if
(
time
>
=
60
)
{
time
/=
60
;
unit
=
"m"
;
if
(
time
>
60
)
{
if
(
time
>
=
60
)
{
time
/=
60
;
unit
=
"h"
;
if
(
time
>
24
)
{
if
(
time
>
=
24
)
{
time
/=
24
;
unit
=
"d"
;
}
...
...
src/methods/Method.java
View file @
f2beb02f
...
...
@@ -42,7 +42,7 @@ public abstract class Method implements Serializable {
private
List
<
Double
>
scoresAUC
;
private
List
<
Double
>
scoresMAP
;
private
List
<
Double
>
scoresDCT
;
private
List
<
Double
>
scoresT
S
;
private
List
<
Double
>
scoresT
D
;
private
List
<
List
<
Double
>>
scoresListCMC
;
private
List
<
List
<
Double
>>
scoresListFARFRR0
;
private
List
<
List
<
Double
>>
scoresListFARFRR1
;
...
...
@@ -244,7 +244,7 @@ public abstract class Method implements Serializable {
scoresAUC
=
new
ArrayList
();
scoresMAP
=
new
ArrayList
();
scoresDCT
=
new
ArrayList
();
scoresT
S
=
new
ArrayList
();
scoresT
D
=
new
ArrayList
();
scoresListCMC
=
new
ArrayList
();
for
(
int
rank
=
0
;
rank
<
classesEvaluation
;
rank
++)
{
scoresListCMC
.
add
(
new
ArrayList
());
...
...
@@ -266,7 +266,7 @@ public abstract class Method implements Serializable {
}
private
void
printEvaluation
()
{
System
.
out
.
print
(
"DBI,DI,SC,FDR,CCR,EER,AUC,MAP,DCT,T
S
\r\n"
);
System
.
out
.
print
(
"DBI,DI,SC,FDR,CCR,EER,AUC,MAP,DCT,T
D
\r\n"
);
System
.
out
.
print
(
toString
(
scoresDBI
));
System
.
out
.
print
(
toString
(
scoresDI
));
System
.
out
.
print
(
toString
(
scoresSC
));
...
...
@@ -276,7 +276,7 @@ public abstract class Method implements Serializable {
System
.
out
.
print
(
toString
(
scoresAUC
));
System
.
out
.
print
(
toString
(
scoresMAP
));
System
.
out
.
print
(
toString
(
scoresDCT
));
System
.
out
.
print
(
toString
(
scoresT
S
));
System
.
out
.
print
(
toString
(
scoresT
D
));
System
.
out
.
print
(
"\r\n"
);
System
.
out
.
print
(
"CMC\r\n"
);
for
(
List
<
Double
>
scoresCMC
:
scoresListCMC
)
{
...
...
@@ -410,7 +410,7 @@ public abstract class Method implements Serializable {
List
<
Double
>
scoresAttemptAUC
=
new
ArrayList
();
List
<
Double
>
scoresAttemptMAP
=
new
ArrayList
();
List
<
Double
>
scoresAttemptDCT
=
new
ArrayList
();
List
<
Double
>
scoresAttemptT
S
=
new
ArrayList
();
List
<
Double
>
scoresAttemptT
D
=
new
ArrayList
();
List
<
List
<
Double
>>
scoresListAttemptCMC
=
new
ArrayList
();
for
(
int
rank
=
0
;
rank
<
numberOfClassesEvaluation
;
rank
++)
{
scoresListAttemptCMC
.
add
(
new
ArrayList
());
...
...
@@ -429,29 +429,10 @@ public abstract class Method implements Serializable {
scoresListAttemptRCLPCN0
.
add
(
new
ArrayList
());
scoresListAttemptRCLPCN1
.
add
(
new
ArrayList
());
}
int
size
=
templatesEvaluation
.
size
();
DistanceMatrix
distanceMatrix
=
new
DistanceMatrix
(
classifier
.
getDistanceTemplates
());
long
beginning
=
System
.
currentTimeMillis
();
int
k
=
0
;
//
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
j
=
0
;
j
<
size
;
j
++)
{
distanceMatrix
.
putDistance
(
templatesEvaluation
.
get
(
i
),
templatesEvaluation
.
get
(
j
));
int
pBefore
=
(
100
*
k
)
/
(
size
*
size
);
//
k
++;
//
int
pAfter
=
(
100
*
k
)
/
(
size
*
size
);
//
long
time
=
System
.
currentTimeMillis
()
-
beginning
;
//
if
(
pBefore
<
pAfter
)
{
//
System
.
out
.
println
(
Executor
.
printTime
(
time
)
+
": "
+
pAfter
+
"%, remaining: "
+
Executor
.
printTime
(
100
*
time
/
pAfter
-
time
));
//
}
//
}
}
scoresAttemptDCT
.
add
(
getDistanceComputationTime
(
beginning
,
size
*
size
));
scoresAttemptTS
.
add
(
getTemplateSize
(
templatesEvaluation
));
// distanceMatrix.print();
// exportCSV(getName() + "_" + System.currentTimeMillis() + ".csv", templatesEvaluation);
long
begin
=
System
.
currentTimeMillis
();
classifier
.
setDistanceMatrix
(
distanceMatrix
);
retriever
.
setDistanceMatrix
(
distanceMatrix
);
setDistanceMatrix
(
templatesEvaluation
);
scoresAttemptDCT
.
add
((
System
.
currentTimeMillis
()
-
beginning
)
/
Math
.
pow
(
templatesEvaluation
.
size
(),
2
));
scoresAttemptTD
.
add
(
getTemplateDimensionality
(
templatesEvaluation
));
List
<
List
<
Template
>>
foldsEvaluation
=
new
ArrayList
();
for
(
int
fFoldEvaluation
=
0
;
fFoldEvaluation
<
nFoldsEvaluation
;
fFoldEvaluation
++)
{
foldsEvaluation
.
add
(
new
ArrayList
());
...
...
@@ -584,7 +565,7 @@ public abstract class Method implements Serializable {
scoresAUC
.
add
(
getAverage
(
scoresAttemptAUC
));
scoresMAP
.
add
(
getAverage
(
scoresAttemptMAP
));
scoresDCT
.
add
(
getAverage
(
scoresAttemptDCT
));
scoresT
S
.
add
(
getAverage
(
scoresAttemptT
S
));
scoresT
D
.
add
(
getAverage
(
scoresAttemptT
D
));
for
(
int
rank
=
0
;
rank
<
numberOfClassesEvaluation
;
rank
++)
{
scoresListCMC
.
get
(
rank
).
add
(
getAverage
(
scoresListAttemptCMC
.
get
(
rank
)));
}
...
...
@@ -596,7 +577,6 @@ public abstract class Method implements Serializable {
scoresListRCLPCN0
.
get
(
f
).
add
(
getAverage
(
scoresListAttemptRCLPCN0
.
get
(
f
)));
scoresListRCLPCN1
.
get
(
f
).
add
(
getAverage
(
scoresListAttemptRCLPCN1
.
get
(
f
)));
}
System
.
out
.
println
(
"time="
+
Executor
.
printTime
(
System
.
currentTimeMillis
()
-
begin
));
}
private
List
<
double
[]>
sortCurve
(
List
<
double
[]>
curve
,
int
index
)
{
...
...
@@ -625,6 +605,27 @@ public abstract class Method implements Serializable {
return
sum
/
scores
.
size
();
}
private
void
setDistanceMatrix
(
List
<
Template
>
templatesEvaluation
)
{
DistanceMatrix
distanceMatrix
=
new
DistanceMatrix
(
classifier
.
getDistanceTemplates
());
int
size
=
templatesEvaluation
.
size
();
long
beginning
=
System
.
currentTimeMillis
();
//
int
k
=
0
;
//
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
j
=
0
;
j
<
size
;
j
++)
{
distanceMatrix
.
putDistance
(
templatesEvaluation
.
get
(
i
),
templatesEvaluation
.
get
(
j
));
int
pBefore
=
(
100
*
k
)
/
(
size
*
size
);
//
k
++;
//
int
pAfter
=
(
100
*
k
)
/
(
size
*
size
);
//
long
time
=
System
.
currentTimeMillis
()
-
beginning
;
//
if
(
pBefore
<
pAfter
)
{
//
System
.
out
.
println
(
Executor
.
printTime
(
time
)
+
": "
+
pAfter
+
"%, remaining: "
+
Executor
.
printTime
(
100
*
time
/
pAfter
-
time
));
//
}
//
}
}
classifier
.
setDistanceMatrix
(
distanceMatrix
);
retriever
.
setDistanceMatrix
(
distanceMatrix
);
}
private
double
[]
getCumulativeMatchCharacteristic
(
List
<
Template
>
templatesTest
,
List
<
Template
>
templatesGallery
)
{
List
<
List
<
Template
>>
split
=
new
ClassifiableList
(
templatesGallery
).
splitClasses
();
int
classes
=
split
.
size
();
...
...
@@ -799,18 +800,14 @@ public abstract class Method implements Serializable {
return
centroid
;
}
public
double
getTemplate
Size
(
List
<
Template
>
templatesEvaluation
)
{
public
double
getTemplate
Dimensionality
(
List
<
Template
>
templatesEvaluation
)
{
int
sum
=
0
;
for
(
Template
sa
mple
:
templatesEvaluation
)
{
sum
+=
sa
mple
.
getDimension
()
*
sa
mple
.
getLength
();
for
(
Template
te
mpl
at
e
:
templatesEvaluation
)
{
sum
+=
te
mpl
at
e
.
getDimension
()
*
te
mpl
at
e
.
getLength
();
}
return
(
double
)
sum
/
templatesEvaluation
.
size
();
}
public
double
getDistanceComputationTime
(
long
beginning
,
int
numberOfClassifications
)
{
return
(
double
)
(
System
.
currentTimeMillis
()
-
beginning
)
/
numberOfClassifications
;
}
public
double
[]
getFARFRR
(
double
radius
,
List
<
Template
>
templatesTest
,
List
<
Template
>
templatesGallery
)
{
double
far
=
0
;
double
frr
=
0
;
...
...
@@ -995,7 +992,7 @@ public abstract class Method implements Serializable {
return
rtv
;
}
private
void
exportCSV
(
String
fileNameCSV
,
List
<
Template
>
templates
)
{
private
void
export
TemplatesTo
CSV
(
String
fileNameCSV
,
List
<
Template
>
templates
)
{
try
{
System
.
out
.
print
(
"saving "
+
fileNameCSV
+
"\r\n"
);
FileWriter
writer
=
new
FileWriter
(
fileNameCSV
);
...
...
src/methods/MethodGavrilova.java
View file @
f2beb02f
package
methods
;
import
algorithms.Classifier
;
import
algorithms.ClassifierKNNMV
;
import
algorithms.Classifier1NN
;
import
algorithms.DistanceTemplatesDTW
;
import
algorithms.DistanceVectors
;
import
algorithms.DistanceVectorsL1
;
import
algorithms.RetrieverKNNQuery
;
import
executor.Executor
;
import
java.io.File
;
import
java.io.IOException
;
...
...
@@ -14,7 +11,6 @@ import java.util.List;
import
objects.Feature
;
import
objects.Motion
;
import
objects.MotionJointCoordinates
;
import
objects.Template
;
public
class
MethodGavrilova
extends
Method
{
...
...
@@ -28,15 +24,7 @@ public class MethodGavrilova extends Method {
@Override
public
void
learnClassifier
(
List
<
Motion
>
motionsLearning
)
{
ClassifierGavrilova
classifier
=
new
ClassifierGavrilova
();
DistanceTemplatesDTW
distanceTemplatesJRD
=
new
DistanceTemplatesDTW
();
DistanceTemplatesDTW
distanceTemplatesJRA
=
new
DistanceTemplatesDTW
();
DistanceVectorsGavrilovaJRD
distanceVectorsJRD
=
new
DistanceVectorsGavrilovaJRD
();
DistanceVectorsGavrilovaJRA
distanceVectorsJRA
=
new
DistanceVectorsGavrilovaJRA
();
distanceTemplatesJRD
.
setDistanceVectors
(
distanceVectorsJRD
);
distanceTemplatesJRA
.
setDistanceVectors
(
distanceVectorsJRA
);
classifier
.
setDistanceTemplatesJRD
(
distanceTemplatesJRD
);
classifier
.
setDistanceTemplatesJRA
(
distanceTemplatesJRA
);
Classifier1NN
classifier
=
new
Classifier1NN
();
DistanceTemplatesDTW
distanceTemplates
=
new
DistanceTemplatesDTW
();
distanceTemplates
.
setDistanceVectors
(
new
DistanceVectorsL1
());
classifier
.
setDistanceTemplates
(
distanceTemplates
);
...
...
@@ -85,80 +73,4 @@ public class MethodGavrilova extends Method {
features
.
add
(
motionMJC
.
extractJointAngleFeature
(
"rhipjoint"
,
"root"
,
"rtibia"
));
return
features
;
}
public
class
ClassifierGavrilova
extends
Classifier
{
private
final
int
k
=
3
;
// 3-NN
private
DistanceTemplatesDTW
distanceFunctionJRD
;
private
DistanceTemplatesDTW
distanceFunctionJRA
;
public
ClassifierGavrilova
()
{
}
public
void
setDistanceTemplatesJRD
(
DistanceTemplatesDTW
distanceFunctionJRD
)
{
this
.
distanceFunctionJRD
=
distanceFunctionJRD
;
}
public
void
setDistanceTemplatesJRA
(
DistanceTemplatesDTW
distanceFunctionJRA
)
{
this
.
distanceFunctionJRA
=
distanceFunctionJRA
;
}
@Override
public
int
classify
(
Template
querySample
,
List
<
Template
>
trainingSamples
)
{
RetrieverKNNQuery
retrieverJRD
=
new
RetrieverKNNQuery
(
k
);
RetrieverKNNQuery
retrieverJRA
=
new
RetrieverKNNQuery
(
k
);
retrieverJRD
.
setDistanceTemplates
(
distanceFunctionJRD
);
retrieverJRA
.
setDistanceTemplates
(
distanceFunctionJRA
);
List
<
Template
>
retrievedJRD
=
retrieverJRD
.
retrieve
(
querySample
,
trainingSamples
);
List
<
Template
>
retrievedJRA
=
retrieverJRA
.
retrieve
(
querySample
,
trainingSamples
);
List
<
Template
>
retrieved
=
new
ArrayList
();
retrieved
.
addAll
(
retrievedJRD
);
retrieved
.
addAll
(
retrievedJRA
);
ClassifierKNNMV
classifier
=
new
ClassifierKNNMV
(
2
*
k
);
DistanceTemplatesDTW
distanceFunction
=
new
DistanceTemplatesDTW
();
distanceFunction
.
setDistanceVectors
(
new
DistanceVectorsL1
());
classifier
.
setDistanceTemplates
(
distanceFunction
);
return
classifier
.
classify
(
querySample
,
retrieved
);
}
}
public
final
class
DistanceVectorsGavrilovaJRD
extends
DistanceVectors
{
public
DistanceVectorsGavrilovaJRD
()
{
}
@Override
public
double
getDistance
(
double
[]
pose1
,
double
[]
pose2
)
{
if
(
pose1
.
length
!=
pose2
.
length
)
{
System
.
out
.
println
(
"wrong dimensions"
);
}
double
distance
=
0
;
for
(
int
d
=
0
;
d
<
pose1
.
length
;
d
++)
{
if
(
d
<=
20
)
{
distance
+=
Math
.
abs
(
pose1
[
d
]
-
pose2
[
d
]);
}
}
return
distance
;
}
}
public
final
class
DistanceVectorsGavrilovaJRA
extends
DistanceVectors
{
public
DistanceVectorsGavrilovaJRA
()
{
}
@Override
public
double
getDistance
(
double
[]
pose1
,
double
[]
pose2
)
{
if
(
pose1
.
length
!=
pose2
.
length
)
{
System
.
out
.
println
(
"wrong dimensions"
);
}
double
distance
=
0
;
for
(
int
d
=
0
;
d
<
pose1
.
length
;
d
++)
{
if
(
d
>=
21
)
{
distance
+=
Math
.
abs
(
pose1
[
d
]
-
pose2
[
d
]);
}
}
return
distance
;
}
}
}
src/methods/Method_MMC.java
View file @
f2beb02f
...
...
@@ -4,6 +4,7 @@ import Jama.Matrix;
import
Jama.SingularValueDecomposition
;
import
algorithms.Classifier
;
import
algorithms.Classifier1NN
;
import
algorithms.ClassifierLinear
;
import
algorithms.DistanceTemplatesBaseline
;
import
algorithms.DistanceVectorsMahalanobis
;
import
executor.Executor
;
...
...
@@ -19,8 +20,8 @@ import objects.Sample;
public
class
Method_MMC
extends
Method
{
private
final
boolean
dataType
=
tru
e
;
// true = BoneRotations, false = JointCoordinates
private
final
Classifier
classifier
=
new
Classifier
1NN
();
// Classifier1NN, ClassifierLinear
private
final
boolean
dataType
=
fals
e
;
// true = BoneRotations, false = JointCoordinates
private
final
Classifier
classifier
=
new
Classifier
Linear
();
// Classifier1NN, ClassifierLinear
private
final
int
length
=
150
;
public
Method_MMC
()
{
...
...
src/methods/Method_PCALDA.java
View file @
f2beb02f
...
...
@@ -4,6 +4,7 @@ import Jama.EigenvalueDecomposition;
import
Jama.Matrix
;
import
algorithms.Classifier
;
import
algorithms.Classifier1NN
;
import
algorithms.ClassifierLinear
;
import
algorithms.DistanceTemplatesBaseline
;
import
algorithms.DistanceVectorsMahalanobis
;
import
com.mkobos.pca_transform.PCA
;
...
...
@@ -20,8 +21,8 @@ import objects.Sample;
public
class
Method_PCALDA
extends
Method
{
private
final
boolean
dataType
=
tru
e
;
// true = BoneRotations, false = JointCoordinates
private
final
Classifier
classifier
=
new
Classifier
1NN
();
// Classifier1NN, ClassifierLinear
private
final
boolean
dataType
=
fals
e
;
// true = BoneRotations, false = JointCoordinates
private
final
Classifier
classifier
=
new
Classifier
Linear
();
// Classifier1NN, ClassifierLinear
private
final
int
length
=
150
;
public
Method_PCALDA
()
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment