Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OpenCV-Hand-Gesture-Control
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David
OpenCV-Hand-Gesture-Control
Commits
1e5c8b20
Commit
1e5c8b20
authored
3 years ago
by
David
Browse files
Options
Downloads
Patches
Plain Diff
Some rewriting of code in gesture matching
parent
d6d8ee0a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
modules/Finger.py
+2
-1
2 additions, 1 deletion
modules/Finger.py
modules/GestureLibs/Gesture.py
+1
-1
1 addition, 1 deletion
modules/GestureLibs/Gesture.py
modules/GestureLibs/GestureDetector.py
+15
-15
15 additions, 15 deletions
modules/GestureLibs/GestureDetector.py
with
18 additions
and
17 deletions
modules/Finger.py
+
2
−
1
View file @
1e5c8b20
...
...
@@ -16,6 +16,7 @@ class Finger():
cleaned_list
=
[]
cleaned_list
=
Tools
.
select_coords
(
self
.
ids
,
in_list
)
if
cleaned_list
!=
False
:
cleaned_list
.
sort
(
key
=
lambda
x
:
x
[
0
])
...
...
@@ -41,7 +42,7 @@ class Finger():
for
i
in
TrueList
:
if
i
:
true_number
+=
1
if
true_number
-
1
or
true_number
==
TrueListLength
:
if
true_number
-
1
==
TrueListLength
or
true_number
==
TrueListLength
:
return
True
else
:
return
False
...
...
This diff is collapsed.
Click to expand it.
modules/GestureLibs/Gesture.py
+
1
−
1
View file @
1e5c8b20
...
...
@@ -35,7 +35,7 @@ KEYPRESSLIST = ['\t', '\n', '\r', ' ', '!', '"', '#', '$', '%', '&', "'", '(',
class
Gesture
():
def
__init__
(
self
,
name
:
str
,
action
:
list
,
fingers_up
:
lis
t
,
direction
:
str
)
->
None
:
def
__init__
(
self
,
name
:
str
,
action
:
list
,
fingers_up
:
in
t
,
direction
:
str
)
->
None
:
self
.
name
=
name
self
.
action
=
action
self
.
fingers_up
=
fingers_up
...
...
This diff is collapsed.
Click to expand it.
modules/GestureLibs/GestureDetector.py
+
15
−
15
View file @
1e5c8b20
...
...
@@ -54,16 +54,17 @@ class GestureDetector:
return
False
def
start_detection
(
self
,
input_list
):
if
self
.
in_cooldown
:
print
(
f
"
In cooldown, cooldown ends in
{}
"
,
int
(
self
.
cooldown_end
-
time
.
time
()))
if
int
(
time
.
time
())
>
self
.
cooldown_end
:
self
.
in_cooldown
=
False
if
self
.
in_cooldown
and
self
.
cooldown_end
!=
None
:
print
(
f
"
In cooldown, cooldown ends in
{
0
}
"
,
int
(
self
.
cooldown_end
-
time
.
time
()))
if
int
(
time
.
time
())
>
self
.
cooldown_end
:
self
.
in_cooldown
=
False
if
self
.
detection_start
==
False
and
self
.
in_cooldown
==
False
:
fingers_up
=
[]
print
(
self
.
FingersList
)
for
finger
in
self
.
FingersList
:
finger_is_up
=
finger
.
is_up
(
input_list
)
if
finger_is_up
==
True
:
print
(
"
Up
"
)
fingers_up
.
append
(
True
)
...
...
@@ -87,7 +88,7 @@ class GestureDetector:
self
.
end_time
=
time
.
time
()
+
self
.
detection_window
self
.
number_start
=
1
if
self
.
detection_start
==
True
and
self
.
number_start
==
1
:
if
self
.
detection_start
==
True
and
self
.
number_start
==
1
and
self
.
end_time
!=
None
:
now
=
int
(
time
.
time
())
if
now
<=
self
.
end_time
:
self
.
detection_frames
.
append
(
input_list
)
...
...
@@ -147,20 +148,19 @@ class GestureDetector:
def
match_gesture
(
self
):
# Match previous information to a gesture
UpIDList
=
[]
UpList
=
[]
DirectionsList
=
[]
number_fingers_up
=
int
()
GestureDirection
=
""
"""
Plan for rewrite
"""
for
fingertip
in
self
.
FingerTipsData
:
DirectionsList
.
append
(
fingertip
.
direction
)
for
finger
in
self
.
Finger
sList
:
for
finger
in
self
.
Finger
TipsData
:
if
finger
.
is_up
:
UpIDList
.
append
(
finger
.
tip
)
UpList
.
append
(
finger
)
number_fingers_up
+=
1
for
fingertip
in
self
.
FingerTipsData
:
if
fingertip
.
id
in
UpIDList
:
DirectionsList
.
append
(
fingertip
.
direction
)
# To find the majority of the directions of fingers, the fingers direction have to be mapped to an integer value
DirectionsList
=
convert_dir_id
(
DirectionsList
)
GestureDirection
=
findMajority
(
DirectionsList
)
...
...
@@ -168,7 +168,7 @@ class GestureDetector:
try
:
for
gesture
in
self
.
GestureList
:
# Now matches gesture with the GestureList that was imported from main
if
GestureDirection
==
gesture
.
direction
and
is_identical
(
UpList
,
gesture
.
fingers_up
)
:
if
GestureDirection
==
gesture
.
direction
and
number_fingers_up
==
gesture
.
fingers_up
:
gesture
.
exec_action
()
else
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment