Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
DDC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GOKA HARSHITH
DDC
Commits
6be90ce3
Commit
6be90ce3
authored
Jun 30, 2016
by
Harshith Goka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LagQueue added
parent
8f11fdf2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
195 additions
and
3 deletions
+195
-3
app/src/main/java/com/example/harshith/ddc/DTW.java
app/src/main/java/com/example/harshith/ddc/DTW.java
+1
-1
app/src/main/java/com/example/harshith/ddc/LagQueue.java
app/src/main/java/com/example/harshith/ddc/LagQueue.java
+192
-0
app/src/main/java/com/example/harshith/ddc/ReceiveDataThread.java
...main/java/com/example/harshith/ddc/ReceiveDataThread.java
+2
-2
No files found.
app/src/main/java/com/example/harshith/ddc/DTW.java
View file @
6be90ce3
...
@@ -67,7 +67,7 @@ class DTW{
...
@@ -67,7 +67,7 @@ class DTW{
minAccDistProcess
();
minAccDistProcess
();
return
minAccDist
[
m
][
n
];
return
minAccDist
[
m
-
1
][
n
-
1
];
}
}
public
int
sdtwDistance
(){
public
int
sdtwDistance
(){
...
...
app/src/main/java/com/example/harshith/ddc/LagQueue.java
0 → 100644
View file @
6be90ce3
package
com.example.harshith.ddc
;
class
LagQueue
{
public
int
noOfSlots
=
2000
;
public
int
noOfGestures
;
public
DynamicGesture
[]
gesture
;
public
int
[]
minDtwGap
;
public
Live
[]
liveElement
;
public
boolean
[]
shortlist
;
public
int
latestElement
=
-
1
;
public
int
[]
threshold
;
public
int
lowerBoundary
=
-
200
;
public
int
upperBoundary
=
-
50
;
public
LagQueue
(
DynamicGesture
[]
gest
,
int
[]
threshold
){
gesture
=
gest
.
clone
();
noOfGestures
=
gesture
.
length
;
this
.
threshold
=
threshold
.
clone
();
liveElement
=
new
Live
[
noOfSlots
];
shortlist
=
new
boolean
[
noOfGestures
];
for
(
int
j
=
0
;
j
<
noOfGestures
;
j
++)
{
shortlist
[
j
]
=
true
;
}
minDtwGap
=
new
int
[
noOfGestures
];
}
public
void
overflowCheck
(){
/* if(latestElement == foremostElement){
System.out.print("\n");
System.out.println("#########################");
System.out.println("#### Queue Overflow! ####");
System.out.println("##### Bogus follows #####");
System.out.println("#########################");
}*/
}
public
void
updateQueue
(
Live
live
){
latestElement
=
(
latestElement
+
1
)%
noOfSlots
;
liveElement
[
latestElement
]
=
new
Live
(
live
);
for
(
int
i
=
0
;
i
<
noOfGestures
;
i
++)
{
shortlist
[
i
]
=
true
;
}
overflowCheck
();
}
public
int
getShortlistCount
(){
int
count
=
0
;
for
(
int
i
=
0
;
i
<
noOfGestures
;
i
++)
{
if
(
shortlist
[
i
])
count
++;
}
return
count
;
}
public
int
firstShortlistGestureIndex
(){
int
i
;
for
(
i
=
0
;
i
<
noOfGestures
;
i
++)
{
if
(
shortlist
[
i
])
break
;
}
return
i
;
}
public
boolean
warpFit
(
int
gestIndex
,
int
slot
,
int
tail
){
// thresholdupdate();
return
true
;
}
public
int
[][]
liveTempArrayComp
(
int
slotNo
,
int
gestNo
){
int
[][]
x
=
new
int
[
latestElement
-
(
lowerBoundary
+
slotNo
)][
gesture
[
gestNo
].
getConsiderCount
()];
int
index
=
0
;
for
(
int
i
=
0
;
i
<
liveElement
[
slotNo
].
sensors
;
i
++){
if
(
gesture
[
gestNo
].
consider
[
i
]){
for
(
int
j
=
lowerBoundary
+
slotNo
+
latestElement
;
j
<
latestElement
;
j
++)
{
x
[
j
-
(
lowerBoundary
+
slotNo
+
latestElement
)][
index
]
=
liveElement
[
j
].
reading
[
i
];
//gesture[gestNo].point[j][i];
}
index
++;
}
}
return
x
;
}
public
int
[][]
validSensorArrayComp
(
int
gestNo
){
int
[][]
x
=
new
int
[
gesture
[
gestNo
].
dataPoints
][
gesture
[
gestNo
].
getConsiderCount
()];
int
index
=
0
;
for
(
int
i
=
0
;
i
<
gesture
[
gestNo
].
sensors
;
i
++){
if
(
gesture
[
gestNo
].
consider
[
i
]){
for
(
int
j
=
0
;
j
<
gesture
[
gestNo
].
dataPoints
;
j
++)
{
x
[
j
][
index
]
=
gesture
[
gestNo
].
point
[
j
][
i
];
}
index
++;
}
}
return
x
;
}
public
int
arrayMin
(
int
[]
arr
){
int
mini
=
1000000
;
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
mini
=
Math
.
min
(
arr
[
i
],
mini
);
}
return
mini
;
}
public
int
minDtwGapProcess
(
int
gestNo
){
int
[]
dtwValues
=
new
int
[
upperBoundary
-
lowerBoundary
];
DTW
x
;
int
[][]
gestarraytemp
=
validSensorArrayComp
(
gestNo
);
for
(
int
i
=
0
;
i
<
upperBoundary
-
lowerBoundary
;
i
++)
{
x
=
new
DTWtwoD
();
int
[][]
arraytemp
=
liveTempArrayComp
(
i
,
gestNo
);
x
.
arrayInput
(
gestarraytemp
,
arraytemp
);
//dtwGap[slotNo][i].add( Math.max( 0.0, (x.sdtwDistance() + dtwGap[slotNo][i].size()*alterFactor)) );
dtwValues
[
i
]
=
x
.
dtwDistance
();
}
return
arrayMin
(
dtwValues
);
}
public
void
processQueue
(){
for
(
int
i
=
0
;
i
<
noOfGestures
;
i
++)
{
minDtwGap
[
i
]
=
minDtwGapProcess
(
i
);
}
}
public
int
proceedExecution
(){
for
(
int
i
=
0
;
i
<
noOfGestures
;
i
++)
{
if
(
minDtwGap
[
i
]<=
threshold
[
i
])
shortlist
[
i
]
=
true
;
else
shortlist
[
i
]
=
false
;
}
if
(
getShortlistCount
()==
0
)
latestElement
=
(
latestElement
+
1
)%
noOfSlots
;
else
if
(
getShortlistCount
()==
1
)
{
//gesture execute
System
.
out
.
println
(
firstShortlistGestureIndex
());
return
firstShortlistGestureIndex
();
}
overflowCheck
();
return
-
1
;
}
public
void
print
(){
System
.
out
.
print
(
'\n'
);
System
.
out
.
println
(
"Live Elements:"
);
for
(
int
i
=
0
;
i
<
liveElement
[
0
].
sensors
;
i
++)
{
for
(
int
j
=
0
;
j
<
noOfSlots
;
j
++)
{
System
.
out
.
print
(
liveElement
[
j
].
reading
[
i
]
+
" "
);
}
System
.
out
.
print
(
'\n'
);
}
gestureStatusPrint
();
}
public
void
gestureStatusPrint
(){
System
.
out
.
print
(
'\n'
);
System
.
out
.
println
(
"DTW Status:"
);
for
(
int
i
=
0
;
i
<
noOfGestures
;
i
++)
{
System
.
out
.
print
(
"Gesture "
+
i
+
" : "
+
minDtwGap
[
i
]);
System
.
out
.
print
(
'\n'
);
}
// System.out.println("Gesture Status:");
// for (int i=0; i<noOfGestures; i++) {
// for (int j=0; j<noOfSlots; j++) {
//
// int d=0;
// if(shortlist[j][i]) d=1;
// System.out.print(d + " ");
// }
// System.out.print('\n');
// }
// System.out.println(foremostElement + " " + latestElement);
}
}
\ No newline at end of file
app/src/main/java/com/example/harshith/ddc/ReceiveDataThread.java
View file @
6be90ce3
...
@@ -183,7 +183,7 @@ public class ReceiveDataThread extends Thread {
...
@@ -183,7 +183,7 @@ public class ReceiveDataThread extends Thread {
threshold
=
new
int
[]{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
threshold
=
new
int
[]{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
DynamicQueue
q
=
new
Dynamic
Queue
(
a
,
threshold
);
LagQueue
q
=
new
Lag
Queue
(
a
,
threshold
);
Live
dynamiclive
=
new
Live
();
Live
dynamiclive
=
new
Live
();
...
@@ -200,7 +200,7 @@ public class ReceiveDataThread extends Thread {
...
@@ -200,7 +200,7 @@ public class ReceiveDataThread extends Thread {
if
(
readings
!=
null
&&
readings
.
length
==
11
)
{
if
(
readings
!=
null
&&
readings
.
length
==
11
)
{
dynamiclive
.
update
(
readings
);
dynamiclive
.
update
(
readings
);
q
.
updateQueue
(
dynamiclive
);
q
.
updateQueue
(
dynamiclive
);
if
(
counter
>
20
)
{
if
(
counter
>
20
1
)
{
q
.
processQueue
();
q
.
processQueue
();
i
=
q
.
proceedExecution
();
i
=
q
.
proceedExecution
();
if
(
i
!=
-
1
)
{
if
(
i
!=
-
1
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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