basic svm

This commit is contained in:
Tibe Habils
2023-05-01 18:06:52 +02:00
parent 672f86c317
commit d9c24df5f4
3 changed files with 54 additions and 4 deletions

View File

@@ -2,15 +2,23 @@ import cv2
from predictions.k_nearest import KNearestNeighbours
from predictions.predictor import Predictor
from predictions.svm_model import SVM
if __name__ == '__main__':
buffer = []
# open webcam stream
cap = cv2.VideoCapture(0)
k = 3
predictor_type = KNearestNeighbours(k)
type_predictor = "svm"
if type_predictor == "knn":
k = 10
predictor_type = KNearestNeighbours(k)
elif type_predictor == "svm":
predictor_type = SVM()
else:
predictor_type = KNearestNeighbours(1)
# embeddings_path = 'embeddings/basic-signs/embeddings.csv'
embeddings_path = 'embeddings/fingerspelling/embeddings.csv'
@@ -39,7 +47,7 @@ if __name__ == '__main__':
label, score = predictor.make_prediction(buffer)
# draw label
cv2.putText(frame, label, (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2, cv2.LINE_AA)
cv2.putText(frame, str(label), (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2, cv2.LINE_AA)
cv2.putText(frame, str(score), (10, 60), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2, cv2.LINE_AA)
# Show the frame