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
3b7cdc75
Commit
3b7cdc75
authored
3 years ago
by
David
Browse files
Options
Downloads
Patches
Plain Diff
Small bugfixes
parent
a4d8764e
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
.gitignore
+1
-1
1 addition, 1 deletion
.gitignore
modules/FingersGenerator.py
+5
-4
5 additions, 4 deletions
modules/FingersGenerator.py
run.py
+36
-30
36 additions, 30 deletions
run.py
with
42 additions
and
35 deletions
.gitignore
+
1
−
1
View file @
3b7cdc75
*.bak
pickled_fingerslist
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
...
...
This diff is collapsed.
Click to expand it.
modules/FingersGenerator.py
+
5
−
4
View file @
3b7cdc75
import
pickle
from
os.
path
import
exists
from
path
lib
import
Path
class
FingersGenerator
:
picklefile
=
r
"
../.
pickled_fingerslist
"
picklefile
=
r
"
pickled_fingerslist
"
def
__init__
(
self
)
->
None
:
pass
...
...
@@ -12,8 +12,9 @@ class FingersGenerator:
import
Finger
# The FingersList variable is stored in a pickle file as it is constant, there is no need to create the list
# every time the program runs
if
not
exists
(
self
.
picklefile
):
path
=
Path
(
self
.
picklefile
)
print
(
path
.
is_file
())
if
not
path
.
is_file
():
# Creates the fingers
Thumb
=
Finger
.
Finger
(
name
=
"
Thumb
"
,
finger_id
=
1
,
ids
=
[
1
,
2
,
3
,
4
])
...
...
This diff is collapsed.
Click to expand it.
run.py
+
36
−
30
View file @
3b7cdc75
...
...
@@ -19,9 +19,6 @@ import cv2
import
time
from
pynput
import
keyboard
import
modules.HandDetector
as
HandDetector
import
modules.GestureLibs.GestureDetector
as
GestureDetector
import
modules.GestureLibs.GestureGenerator
as
GestureGenerator
import
modules.FingersGenerator
as
FingersGenerator
'''
TODO
...
...
@@ -44,14 +41,16 @@ def get_arguments():
debug
=
True
else
:
debug
=
False
camera_dir
=
os
.
environ
[
"
CAMERA_DIR
"
]
if
camera_dir
==
""
:
try
:
camera_dir
=
os
.
environ
[
"
CAMERA_DIR
"
]
except
KeyError
:
camera_dir
=
"
/dev/video0
"
print
(
"
No camera directory specified, going with default /dev/video0
"
)
config_path
=
os
.
environ
[
"
CONFIG_PATH
"
]
if
config_path
==
""
:
try
:
config_path
=
os
.
environ
[
"
CONFIG_PATH
"
]
except
KeyError
:
config_path
=
"
.config
"
print
(
"
config file not specified, defaulting to
'
.config
'"
)
...
...
@@ -68,14 +67,15 @@ class Run:
self
.
camera_dir
=
camera_dir
self
.
config
=
config_path
global
FingersGenerator
import
modules.FingersGenerator
as
FingersGenerator
FingersGenerator
=
FingersGenerator
.
FingersGenerator
()
self
.
FingersList
=
FingersGenerator
.
create_fingers
()
global
GestureGenerator
import
modules.GestureLibs.GestureGenerator
as
GestureGenerator
GestureGenerator
=
GestureGenerator
.
GestureGenerator
(
self
.
config
)
self
.
GestureList
=
GestureGenerator
.
read_config
()
global
GestureDetector
import
modules.GestureLibs.GestureDetector
as
GestureDetector
GestureDetector
=
GestureDetector
.
GestureDetector
()
GestureDetector
.
parse_fingertips
()
...
...
@@ -84,28 +84,34 @@ class Run:
global
logging_list
global
fps_list
capture
=
cv2
.
VideoCapture
(
0
)
capture
=
cv2
.
VideoCapture
(
self
.
camera_dir
)
detector
=
HandDetector
.
HandDetector
()
prevTime
=
0
currTime
=
0
try
:
while
True
:
_
,
frame
=
capture
.
read
()
frame
=
cv2
.
flip
(
frame
,
1
)
frame
=
detector
.
fdHands
(
frame
)
while
True
:
_
,
frame
=
capture
.
read
()
frame
=
cv2
.
flip
(
frame
,
1
)
frame
=
detector
.
fdHands
(
frame
)
lmList
=
detector
.
fdPositions
(
frame
)
logging_list
.
append
(
lmList
)
if
self
.
debug
:
currTime
=
time
.
time
()
fps
=
1
/
(
currTime
-
prevTime
)
prevTime
=
currTime
fps_list
.
append
(
fps
)
lmList
=
detector
.
fdPositions
(
frame
)
logging_list
.
append
(
lmList
)
cv2
.
putText
(
frame
,
str
(
int
(
fps
)),
(
10
,
70
),
cv2
.
FONT_HERSHEY_PLAIN
,
3
,
(
0
,
0
,
255
),
thickness
=
3
)
cv2
.
imshow
(
"
Video
"
,
frame
)
cv2
.
waitKey
(
1
)
if
self
.
debug
:
currTime
=
time
.
time
()
fps
=
1
/
(
currTime
-
prevTime
)
prevTime
=
currTime
fps_list
.
append
(
fps
)
cv2
.
putText
(
frame
,
str
(
int
(
fps
)),
(
10
,
70
),
cv2
.
FONT_HERSHEY_PLAIN
,
3
,
(
0
,
0
,
255
),
thickness
=
3
)
cv2
.
imshow
(
"
Video
"
,
frame
)
cv2
.
waitKey
(
1
)
except
BaseException
as
e
:
print
(
e
)
print
(
"
Video ended
"
)
class
ProcessController
:
...
...
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