Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-099
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2022-099
2022-099
Commits
cb1ae306
Commit
cb1ae306
authored
May 07, 2022
by
AyeshaEwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding basic keys
parent
8d60bf43
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
0 deletions
+70
-0
sign_keyboard.py
sign_keyboard.py
+70
-0
No files found.
sign_keyboard.py
View file @
cb1ae306
...
...
@@ -9,11 +9,81 @@ cap =cv2.VideoCapture(0)
#cap.set(4,720)
detector
=
HandDetector
(
detectionCon
=
0.65
)
keys
=
[[
"Q"
,
"W"
,
"E"
,
"R"
,
"T"
,
"Y"
,
"U"
,
"I"
,
"O"
,
"P"
],
#LIST NO 1
[
"A"
,
"S"
,
"D"
,
"F"
,
"G"
,
"H"
,
"J"
,
"K"
,
"L"
,
";"
],
#LIST NO 2
[
"Z"
,
"X"
,
"C"
,
"V"
,
"B"
,
"N"
,
"M"
,
","
,
"."
,
"/"
]]
#LIST NO 3
final_text
=
""
def
drawALL
(
img
,
buttonList
):
for
button
in
buttonList
:
x
,
y
=
button
.
pos
w
,
h
=
button
.
size
cv2
.
rectangle
(
img
,
button
.
pos
,(
x
+
w
,
y
+
h
),(
100
,
0
,
100
),
cv2
.
FILLED
)
# img, (initial loction),(size)
cv2
.
putText
(
img
,
button
.
text
,
(
x
+
10
,
y
+
35
),
cv2
.
FONT_HERSHEY_PLAIN
,
2
,(
255
,
255
,
255
),
2
)
return
img
class
Button
():
def
__init__
(
self
,
pos
,
text
,
size
=
[
49
,
54
]):
self
.
pos
=
pos
self
.
size
=
size
self
.
text
=
text
buttonlist
=
[]
for
i
in
range
(
len
(
keys
))
:
for
j
,
key
in
enumerate
(
keys
[
i
])
:
buttonlist
.
append
(
Button
([
60
*
j
+
20
,
100
*
i
+
50
],
key
))
while
True
:
success
,
img
=
cap
.
read
()
img
=
cv2
.
flip
(
img
,
1
)
hands
,
img
=
detector
.
findHands
(
img
,
flipType
=
False
)
#with draw
img
=
drawALL
(
img
,
buttonlist
)
if
hands
:
#hand 1
hand1
=
hands
[
0
]
#detecting only one hand
lmList1
=
hand1
[
"lmList"
]
#21 parameters,21 landmarks points
#lmList2 = hand1["lmList"]
bbox1
=
hand1
[
"bbox"
]
#bounding box info x,y,w,h
centerPoint1
=
hand1
[
"center"
]
#gives center of the hand cx and cy
handType1
=
hand1
[
"type"
]
#hand type left or right
if
lmList1
:
for
button
in
buttonlist
:
x
,
y
=
button
.
pos
w
,
h
=
button
.
size
if
x
<
lmList1
[
8
][
0
]
<
x
+
w
and
y
<
lmList1
[
8
][
1
]
<
y
+
h
:
#index finger tip
cv2
.
rectangle
(
img
,
button
.
pos
,(
x
+
w
,
y
+
h
),(
195
,
0
,
195
),
cv2
.
FILLED
)
# img, (initial loction),(size)
cv2
.
putText
(
img
,
button
.
text
,
(
x
+
10
,
y
+
35
),
cv2
.
FONT_HERSHEY_PLAIN
,
2
,(
255
,
255
,
255
),
2
)
length
,
info
=
detector
.
findDistance
(
lmList1
[
8
],
lmList1
[
12
])
#l , _, _ =detector.findDistance(8,12,img)
# print(length)
#when clicked
if
length
<
30
:
cv2
.
rectangle
(
img
,
button
.
pos
,(
x
+
w
,
y
+
h
),(
0
,
255
,
0
),
cv2
.
FILLED
)
# img, (initial loction),(size)
cv2
.
putText
(
img
,
button
.
text
,
(
x
+
10
,
y
+
35
),
cv2
.
FONT_HERSHEY_PLAIN
,
2
,(
255
,
255
,
255
),
2
)
final_text
+=
button
.
text
sleep
(
0.15
)
#how many times we clicked
#final text
cv2
.
rectangle
(
img
,
(
50
,
370
),(
580
,
450
),(
255
,
255
,
255
),
cv2
.
FILLED
)
# img, (initial loction),(size)
cv2
.
putText
(
img
,
final_text
,
(
60
,
430
),
cv2
.
FONT_HERSHEY_PLAIN
,
3
,(
0
,
0
,
0
),
3
)
cv2
.
namedWindow
(
"image"
,
cv2
.
WINDOW_NORMAL
)
# set your desired size
cv2
.
resizeWindow
(
'image'
,
1266
,
668
)
...
...
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