Edited Interface
Browse files
app.py
CHANGED
@@ -6,8 +6,6 @@ import time
|
|
6 |
import gradio as gr
|
7 |
import glob
|
8 |
|
9 |
-
DOMINANT_HAND = "Right"
|
10 |
-
|
11 |
width_, height_, = 144, 96
|
12 |
|
13 |
drawing_flag = False
|
@@ -67,7 +65,7 @@ def clear(landmarks): # brute force finger orientation checking
|
|
67 |
return False
|
68 |
|
69 |
|
70 |
-
def show(video): # main
|
71 |
cam = cv2.VideoCapture(video) # get the video file from path
|
72 |
width = cam.get(cv2.CAP_PROP_FRAME_WIDTH)
|
73 |
height = cam.get(cv2.CAP_PROP_FRAME_HEIGHT)
|
@@ -96,11 +94,11 @@ def show(video): # main
|
|
96 |
if x: # return flag for cv2
|
97 |
try: # for error handling
|
98 |
if hands:
|
99 |
-
hand1 = hands[0] if hands[0]["type"] ==
|
100 |
lm_list1 = hand1["lm_list"] # List of 21 Landmarks
|
101 |
handedness = hand1["type"]
|
102 |
|
103 |
-
if handedness ==
|
104 |
idx_coords = lm_list1[8][0], lm_list1[8][1] # 0 is width (bigger)
|
105 |
# print(idx_coords)
|
106 |
cv2.circle(rgb_image_f, idx_coords, 5, color, cv2.FILLED)
|
@@ -189,6 +187,10 @@ def show(video): # main
|
|
189 |
|
190 |
title = 'Air Draw'
|
191 |
desc = 'A Mediapipe Hands Wrapper for Drawing in the Air'
|
192 |
-
iface = gr.Interface(
|
|
|
|
|
|
|
|
|
193 |
|
194 |
iface.launch(share=True, enable_queue=True)
|
|
|
6 |
import gradio as gr
|
7 |
import glob
|
8 |
|
|
|
|
|
9 |
width_, height_, = 144, 96
|
10 |
|
11 |
drawing_flag = False
|
|
|
65 |
return False
|
66 |
|
67 |
|
68 |
+
def show(video, dominant_hand): # main
|
69 |
cam = cv2.VideoCapture(video) # get the video file from path
|
70 |
width = cam.get(cv2.CAP_PROP_FRAME_WIDTH)
|
71 |
height = cam.get(cv2.CAP_PROP_FRAME_HEIGHT)
|
|
|
94 |
if x: # return flag for cv2
|
95 |
try: # for error handling
|
96 |
if hands:
|
97 |
+
hand1 = hands[0] if hands[0]["type"] == dominant_hand else hands[1]
|
98 |
lm_list1 = hand1["lm_list"] # List of 21 Landmarks
|
99 |
handedness = hand1["type"]
|
100 |
|
101 |
+
if handedness == dominant_hand:
|
102 |
idx_coords = lm_list1[8][0], lm_list1[8][1] # 0 is width (bigger)
|
103 |
# print(idx_coords)
|
104 |
cv2.circle(rgb_image_f, idx_coords, 5, color, cv2.FILLED)
|
|
|
187 |
|
188 |
title = 'Air Draw'
|
189 |
desc = 'A Mediapipe Hands Wrapper for Drawing in the Air'
|
190 |
+
iface = gr.Interface(
|
191 |
+
fn=show,
|
192 |
+
inputs=[gr.inputs.Video(source="webcam", label="Record from Webcam"), gr.inputs.Radio(['Right', 'Left'])],
|
193 |
+
outputs='video', title=title,
|
194 |
+
description=desc)
|
195 |
|
196 |
iface.launch(share=True, enable_queue=True)
|