5월, 2022의 게시물 표시

Snake game using openCV (hand tracking)

이미지
The snake game using openCV, cvzone libraries. Here I will explain the steps for the code. If you need a final code, please check the bottom of the blog. 1. Video 2. Setup the libraries and camera After installing the libraries, you can check if it works using the below code. 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 import cvzone from cvzone.HandTrackingModule import HandDetector import cv2 cap = cv2 . VideoCapture( 0 ) cap . set( 3 , 1280 ) cap . set( 4 , 720 ) detector = HandDetector(detectionCon = 0.8 , maxHands = 1 ) cap = cv2 . VideoCapture( 0 ) # connect camera cap . set( 3 , 1280 ) # set the width and height of the image cap . set( 4 , 720 ) detector = HandDetector(detectionCon = 0.8 , maxHands = 1 ) # set the threshold and the number of hands to detect while True : success, img = cap . read() img = cv2 . flip(img, 1 ) hands, img = detector . findHands(img, flipType = False ) cv2 . imshow(...

OpenCV를 이용한 지렁이게임 (hand tracking)

이미지
opencv, cvzone 라이브러리를 이용한 지렁이 게임 입니다. 코드를 과정 별로 설명한 글입니다. 최종 코드를 보고 싶으시면 가장 아래를 참고 바랍니다. 1. 영상 2. 라이브러리 및 카메라 setup 해당 라이브러리들을 설치하고 잘 실행이 되는지 확인을 위해, 다음 코드를 실행합니다. 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 import cvzone from cvzone.HandTrackingModule import HandDetector import cv2 cap = cv2 . VideoCapture( 0 ) cap . set( 3 , 1280 ) cap . set( 4 , 720 ) detector = HandDetector(detectionCon = 0.8 , maxHands = 1 ) cap = cv2 . VideoCapture( 0 ) # connect camera cap . set( 3 , 1280 ) # set the width and height of the image cap . set( 4 , 720 ) detector = HandDetector(detectionCon = 0.8 , maxHands = 1 ) # set the threshold and the number of hands to detect while True : success, img = cap . read() img = cv2 . flip(img, 1 ) hands, img = detector . findHands(img, flipType = False ) cv2 . imshow( "Image" , img) key = cv2 . waitKey( 1 ) if key == 27 : # key 'esc' ...