Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,6 @@ classifier = Classifier("keras_model.h5", "labels.txt")
|
|
| 11 |
offset = 20
|
| 12 |
imgSize = 300
|
| 13 |
|
| 14 |
-
# Function to classify the hand
|
| 15 |
def classify_hand(img):
|
| 16 |
imgOutput = img.copy()
|
| 17 |
|
|
@@ -53,6 +52,18 @@ def classify_hand(img):
|
|
| 53 |
|
| 54 |
return imgOutput
|
| 55 |
|
| 56 |
-
#
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
offset = 20
|
| 12 |
imgSize = 300
|
| 13 |
|
|
|
|
| 14 |
def classify_hand(img):
|
| 15 |
imgOutput = img.copy()
|
| 16 |
|
|
|
|
| 52 |
|
| 53 |
return imgOutput
|
| 54 |
|
| 55 |
+
# OpenCV function to capture frames from the webcam
|
| 56 |
+
def capture_frames():
|
| 57 |
+
cap = cv2.VideoCapture(0)
|
| 58 |
+
while True:
|
| 59 |
+
success, img = cap.read()
|
| 60 |
+
if not success:
|
| 61 |
+
print("Error: Could not read frame from the camera.")
|
| 62 |
+
break
|
| 63 |
+
processed_img = classify_hand(img)
|
| 64 |
+
cv2.imshow('Hand Gesture Recognition', processed_img)
|
| 65 |
+
if cv2.waitKey(1) & 0xFF == ord('q'):
|
| 66 |
+
break
|
| 67 |
+
|
| 68 |
+
# Start capturing frames
|
| 69 |
+
capture_frames()
|