forked from Ultimecia1463/GTM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
omendra.js
32 lines (27 loc) · 1.11 KB
/
omendra.js
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
31
32
// ... (rest of your existing script.js code)
// Assuming you have a variable called 'prediction' that holds the model's prediction
// and 'prediction.class' contains the gesture class (e.g., "fist", "palm")
// and 'prediction.probability' contains the confidence score (0 to 1)
function moveSquare(prediction) {
const confidenceThreshold = 0.7; // Adjust as needed
if (prediction.probability > confidenceThreshold) {
// Move the square based on the predicted gesture
if (prediction.class === 'fist') {
// Move right
// ... your code to move the square right ...
} else if (prediction.class === 'palm') {
// Move left
// ... your code to move the square left ...
} else if (prediction.class === 'thumbsUp') {
// Move up
// ... your code to move the square up ...
} else if (prediction.class === 'thumbsDown') {
// Move down
// ... your code to move the square down ...
}
} else {
// Ignore the prediction if confidence is below the threshold
console.log("Prediction confidence too low, ignoring.");
}
}
// ... (rest of your script.js code)