Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IT Management Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Formanek Balázs István
IT Management Project
Commits
6e5eebef
Commit
6e5eebef
authored
4 months ago
by
Vajay Mónika
Browse files
Options
Downloads
Patches
Plain Diff
remove left hand actions when it is not detected
parent
c15cf8e7
Branches
main
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
final_project/main.py
+8
-3
8 additions, 3 deletions
final_project/main.py
with
8 additions
and
3 deletions
final_project/main.py
+
8
−
3
View file @
6e5eebef
...
...
@@ -4,6 +4,7 @@ import numpy as np
from
sklearn.ensemble
import
RandomForestClassifier
from
tkinter
import
Tk
,
Label
from
PIL
import
Image
,
ImageTk
import
pyautogui
from
mouse_class
import
Mouse
from
keyboard_class
import
Keyboard
...
...
@@ -96,7 +97,7 @@ def main():
command
=
pred
[
0
]
mouse
.
add_prediction
(
command
)
if
command
==
"
move cursor
"
or
command
==
"
g
ra
b
"
:
if
command
==
"
move cursor
"
or
command
==
"
d
ra
g
"
:
mouse
.
get_hand_size
(
right_landmark_list
[
12
],
right_landmark_list
[
0
])
mouse
.
get_hand_pos
(
right_landmark_list
[
9
])
elif
command
==
"
change the model
"
:
...
...
@@ -119,7 +120,7 @@ def main():
cv2
.
putText
(
img
=
frameRGB
,
text
=
f
"
{
pred
[
0
]
}
pos
{
right_landmark_list
[
8
][
0
]
:
.
2
f
}
,
{
right_landmark_list
[
8
][
1
]
:
.
2
f
}
,
{
MOUSE_ACTIVE
}
"
,
text
=
f
"
{
pred
[
0
]
}
, MOUSE:
{
MOUSE_ACTIVE
}
"
,
org
=
(
30
,
30
),
fontFace
=
cv2
.
FONT_HERSHEY_DUPLEX
,
fontScale
=
1
,
color
=
(
255
,
0
,
0
),
thickness
=
1
)
...
...
@@ -143,11 +144,15 @@ def main():
pred
=
model_specialkeys
.
predict
(
np
.
asarray
(
normalised_left_landmark_list
).
reshape
(
1
,
-
1
))
command
=
pred
[
0
]
cv2
.
putText
(
img
=
frameRGB
,
text
=
pred
[
0
],
org
=
(
30
,
3
0
),
img
=
frameRGB
,
text
=
pred
[
0
],
org
=
(
30
,
6
0
),
fontFace
=
cv2
.
FONT_HERSHEY_DUPLEX
,
fontScale
=
1
,
color
=
(
0
,
255
,
0
),
thickness
=
1
)
specialkeys
.
add_prediction
(
command
)
else
:
pyautogui
.
keyUp
(
'
shift
'
)
pyautogui
.
keyUp
(
'
ctrl
'
)
pyautogui
.
keyUp
(
'
alt
'
)
# Convert frame to Tkinter-compatible format and display
frameRGB_resized
=
cv2
.
resize
(
frameRGB
,
(
root
.
winfo_width
(),
root
.
winfo_height
()))
...
...
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