import cv2
cap = cv2.VideoCapture(0)
while cap.isOpened():
ret, img = cap.read()
if not ret:
break
cv2.imshow('video',img)
if cv2.waitKey(33) == 49:
break
cap.release()
cv2.destroyAllWindows()
mediapipe의 손을 찾을 때는 21개의 특징점이 존재한다.
import cv2
import mediapipe as mp
mp_hands = mp.solutions.hands
cap = cv2.VideoCapture(0)
while cap.isOpened():
ret, img = cap.read()
if not ret:
break
cv2.imshow('video',img)
if cv2.waitKey(33) == 49:
break
cap.release()
cv2.destroyAllWindows()
import cv2
import mediapipe as mp
mp_hands = mp.solutions.hands
#특징점 그리기 설정
mp_drawing = mp.solutions.drawing_utils
#손 특징점 찾기 관련 설정
hands = mp_hands.Hands(
max_num_hands =2, #손의 갯수
min_detection_confidence = 0.5, #손 검출 확률
min_tracking_confidence = 0.5 #특징점 검출 확률
)
cap = cv2.VideoCapture(0)
while cap.isOpened():
ret, img = cap.read()
if not ret:
break
cv2.imshow('video',img)
if cv2.waitKey(33) == 49:
break
cap.release()
cv2.destroyAllWindows()
import cv2
import mediapipe as mp
mp_hands = mp.solutions.hands
#특징점 그리기 설정
mp_drawing = mp.solutions.drawing_utils
#손 특징점 찾기 관련 설정
hands = mp_hands.Hands(
max_num_hands =2, #손의 갯수
min_detection_confidence = 0.5, #손 검출 확률
min_tracking_confidence = 0.5 #특징점 검출 확률
)
cap = cv2.VideoCapture(0)
while cap.isOpened():
ret, img = cap.read()
img = cv2.flip(img,1)
if not ret:
break
cv2.imshow('video',img)
if cv2.waitKey(33) == 49:
break
cap.release()
cv2.destroyAllWindows()
import cv2
import mediapipe as mp
mp_hands = mp.solutions.hands
#특징점 그리기 설정
mp_drawing = mp.solutions.drawing_utils
#손 특징점 찾기 관련 설정
hands = mp_hands.Hands(
max_num_hands =2, #손의 갯수
min_detection_confidence = 0.5, #손 검출 확률
min_tracking_confidence = 0.5 #특징점 검출 확률
)
cap = cv2.VideoCapture(0)
while cap.isOpened():
ret, img = cap.read()
img = cv2.flip(img,1)
if not ret:
break
#이미지에서 원하는 대상(손) 찾기
result = hands.process(img)
cv2.imshow('video',img)
if cv2.waitKey(33) == 49:
break
cap.release()
cv2.destroyAllWindows()
import cv2
import mediapipe as mp
mp_hands = mp.solutions.hands
#특징점 그리기 설정
mp_drawing = mp.solutions.drawing_utils
#손 특징점 찾기 관련 설정
hands = mp_hands.Hands(
max_num_hands =2, #손의 갯수
min_detection_confidence = 0.5, #손 검출 확률
min_tracking_confidence = 0.5 #특징점 검출 확률
)
cap = cv2.VideoCapture(0)
while cap.isOpened():
ret, img = cap.read()
img = cv2.flip(img,1)
if not ret:
break
#이미지에서 원하는 대상(손) 찾기
result = hands.process(img)
#손을 검출했다면 표현하기(21개의 특징점을 찾음)
if result.multi_hand_landmarks is not None:
#21개의 특징점을 하나씩 그려주기
for res in result.multi_hand_landmarks:
mp_drawing.draw_landmarks(img, res, mp_hands.HAND_CONNECTIONS)
cv2.imshow('video',img)
if cv2.waitKey(33) == 49:
break
cap.release()
cv2.destroyAllWindows()
import numpy, KNeighborsClassifier
import cv2
import mediapipe as mp
gesture = {
0:'fist', 1:'one', 2:'two', 3:'three', 4:'four', 5:'five',
6:'six', 7:'rock', 8:'spiderman', 9:'yeah', 10:'ok',
}
#gesture_train을 머신러닝 모델에 학습
import numpy as np
file = np.genfromtxt('images/gesture_train.csv',delimiter = ',')
angle = file[:,:-1].astype(np.float32) #문제데이터
label = file[:,-1].astype(np.float32) #정답데이터
from sklearn.neighbors import KNeighborsClassifier
knn = KNeighborsClassifier(n_neighbors=3)
knn.fit(angle,label)
mp_hands = mp.solutions.hands
#특징점 그리기 설정
mp_drawing = mp.solutions.drawing_utils
#손 특징점 찾기 관련 설정
hands = mp_hands.Hands(
max_num_hands =1, #손의 갯수
min_detection_confidence = 0.5, #손 검출 확률
min_tracking_confidence = 0.5 #특징점 검출 확률
)
cap = cv2.VideoCapture(0)
while cap.isOpened():
ret, img = cap.read()
img = cv2.flip(img,1)
if not ret:
break
#이미지에서 원하는 대상(손) 찾기
result = hands.process(img)
#손을 검출했다면 표현하기(21개의 특징점을 찾음)
if result.multi_hand_landmarks is not None:
#21개의 특징점을 하나씩 그려주기
for res in result.multi_hand_landmarks:
mp_drawing.draw_landmarks(img, res, mp_hands.HAND_CONNECTIONS)
cv2.imshow('video',img)
if cv2.waitKey(33) == 49:
break
cap.release()
cv2.destroyAllWindows()