-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessing.py
More file actions
30 lines (23 loc) · 1004 Bytes
/
Copy pathprocessing.py
File metadata and controls
30 lines (23 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import json
import numpy as np
# Define the hand signs (this should match what you defined in Step 1)
hand_signs = ['hello', 'thank_you', 'yes', 'no','OK','Peace','Good Job','A', 'B', 'C', 'D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] # Ensure this matches your capturing step
# Load the landmark data
with open('hand_signs/landmarks.json', 'r') as f:
landmark_data = json.load(f)
# Prepare features (X) and labels (y)
X = []
y = []
label_map = {sign: index for index, sign in enumerate(hand_signs)}
for sign, landmarks_list in landmark_data.items():
for landmarks in landmarks_list:
# Flatten the landmark list and normalize
flat_landmarks = np.array(landmarks).flatten()
X.append(flat_landmarks)
y.append(label_map[sign])
X = np.array(X)
y = np.array(y)
# Save X and y for training
np.save('hand_signs/X.npy', X)
np.save('hand_signs/y.npy', y)
print("Data preparation complete. Features and labels saved.")