Skip to content

ogzmsl/HandDetection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Python Hand Detection

Python with OpenCV - MediaPip Framework Hand Detection
Explore the docs »

Contact Me

About The Project

product-screenshot

It is a Computer vision package that makes it easy to operate image processing and AI functions. It mainly uses OpenCV and Google Mediapipe libraries.

Usage areas

  • Military Industry (submarine sonic wave scans), underwater imaging.
  • Security, criminal laboratories.
  • Medicine.
  • Clarification of structures such as tumors, vessels, Tomography, Ultrasound.
  • Robotics, traffic, astronomy, radar, newspaper and photography industry applications
  • Etc..

Here we just do hand identification with a computer camera based on the basics.

(back to top)

Built With

Libraries and programming language I use.

(back to top)

Getting Started

The materials you need to do this.

Installation

· Install PIP packages

! pip install opencv
! pip install mediapip
! pip install numpy

(back to top)

Usage

Basic Code Example

import cvzone
import cv2

cap = cv2.VideoCapture(0)
cap.set(3, 1280)
cap.set(4, 720)
detector = cvzone.HandDetector(detectionCon=0.5, maxHands=1)

while True:
    # Get image frame
    success, img = cap.read()

    # Find the hand and its landmarks
    img = detector.findHands(img)
    lmList, bbox = detector.findPosition(img)
    
    # Display
    cv2.imshow("Image", img)
    cv2.waitKey(1)

Finding How many finger are up

if lmList:
fingers = detector.fingersUp()
totalFingers = fingers.count(1)
cv2.putText(img, f'Fingers:{totalFingers}', (bbox[0] + 200, bbox[1] - 30),
            cv2.FONT_HERSHEY_PLAIN, 2, (0, 255, 0), 2)

(back to top)

My Hand Detection

my-handDetection

import mediapipe as mp
import cv2
import numpy as np 

mp_drawing = mp.solutions.drawing_utils
mp_hands = mp.solutions.hands

cap = cv2.VideoCapture(0)
with mp_hands.Hands(min_detection_confidence=0.8, min_tracking_confidence=0.5) as hands:
    while cap.isOpened():
        ret, frame = cap.read()
        image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
        image = cv2.flip(image, 1)
        image.flags.writeable = False
        results = hands.process(image)
        image.flags.writeable = True
        image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
        #print(results)
        if results.multi_hand_landmarks:
            for num, hand in enumerate(results.multi_hand_landmarks):
                mp_drawing.draw_landmarks(image, hand, mp_hands.HAND_CONNECTIONS,
                                          mp_drawing.DrawingSpec(color=(217, 133, 0), thickness=2, circle_radius=4),
                                          mp_drawing.DrawingSpec(color=(105, 0, 101), thickness=2, circle_radius=2),)
                cv2.imshow('HandTracking', image)
                if cv2.waitKey(10) & 0xFF == ord('q'):
                    break
cap.release()
cv2.destroyAllWindows()
mp_drawing.DrawingSpec()

Contact

Twitter - @filokipatisi
E-Mail - GMAIL
Linkedin - oguzzmuslu

(back to top)

About

With OpenCV hand recognition

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages