'cvzone' has no attribute 'HandDetector'

See original GitHub issue

I tried to run the below mentioned Example code. but I got an Attribute error saying

AttributeError: module ‘cvzone’ has no attribute ‘HandDetector’.

Help me to resolve this issue.

the Example code is.

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)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:11

github_iconTop GitHub Comments

2reactions
Mandizvidzafncommented, Feb 4, 2022

Hey its-Yogesh, what francoisschwarxentruber said is right. Try this:

from cvzone.HandTrackingModule import HandDetector import cv2

cap = cv2.VideoCapture(0) detector = HandDetector(detectionCon=0.8, maxHands=2) while True: # Get image frame success, img = cap.read() # Find the hand and its landmarks hands, img = detector.findHands(img) # with draw #hands = detector.findHands(img, draw=False) # without draw

if hands:
    # Hand 1
    hand1 = hands[0]
    lmList1 = hand1["lmList"]  # List of 21 Landmark points
    bbox1 = hand1["bbox"]  # Bounding box info x,y,w,h
    centerPoint1 = hand1['center']  # center of the hand cx,cy
    handType1 = hand1["type"]  # Handtype Left or Right

    fingers1 = detector.fingersUp(hand1)

    if len(hands) == 2:
        # Hand 2
        hand2 = hands[1]
        lmList2 = hand2["lmList"]  # List of 21 Landmark points
        bbox2 = hand2["bbox"]  # Bounding box info x,y,w,h
        centerPoint2 = hand2['center']  # center of the hand cx,cy
        handType2 = hand2["type"]  # Hand Type "Left" or "Right"

        fingers2 = detector.fingersUp(hand2)

        # Find Distance between two Landmarks. Could be same hand or different hands
        length, info, img = detector.findDistance(lmList1[8], lmList2[8], img)  # with draw
        # length, info = detector.findDistance(lmList1[8], lmList2[8])  # with draw
# Display
cv2.imshow("Image", img)
if cv2.waitKey(1) == ord('q'):
    break

cap.release() cv2.destroyAllWindows()

0reactions
Pixie34commented, Oct 18, 2022

i can´t get the distance between 2 landmarks to show, any help?

from cvzone.HandTrackingModule import HandDetector import cv2

cap = cv2.VideoCapture(0) detector = HandDetector(detectionCon=0.5, maxHands= 1)

while True:

#hacer un cuadro success, img = cap.read()

#detectar las manos y trazar las rayitas hands, img = detector.findHands(img) # with draw

if hands:
    # Mano 1
    hand1 = hands[0]
    lmList1 = hand1["lmList"]  # List of 21 Landmark points
    bbox1 = hand1["bbox"]  # Bounding box info x,y,w,h
    centerPoint1 = hand1['center']  # center of the hand cx,cy
    handType1 = hand1["type"]  # Handtype Left or Right

    fingers1 = detector.fingersUp(hand1)

if len(hands) == 2:
    # Mano 2
    hand2 = hands[1]
    lmList2 = hand2["lmList"]  # List of 21 Landmark points
    bbox2 = hand2["bbox"]  # Bounding box info x,y,w,h
    centerPoint2 = hand2['center']  # center of the hand cx,cy
    handType2 = hand2["type"]  # Hand Type "Left" or "Right"

    fingers2 = detector.fingersUp(hand2)

    # Distancia entre 2 Landmarks. puede ser de la misma mano OJOOOOOO
    length, info, img = detector.findDistance(lmList2[4], lmList2[12], img)  # with draw
        # length, info = detector.findDistance(lmList1[8], lmList2[8])  # with draw

# Display
cv2.imshow("Image", img)
if cv2.waitKey(1) == ord('q'):
    break

cap.release() cv2.destroyAllWindows()

Read more comments on GitHub >

github_iconTop Results From Across the Web

can't find findposition :AttributeError: 'HandDetector' object has ...
I did a lot of projects recently with cvzone and noticed that they recently updated the library with a critical update for their...
Read more >
module 'cvzone' has no attribute 'HandTrackingModule'
hello guys i am new to opencv and was working on a project and imported cvzone lib in pycham but when i am...
Read more >
Even after installing cvzone Im unable to import HandDetector ...
[Solved]-Even after installing cvzone Im unable to import HandDetector from ... AttributeError: 'module' object has no attribute 'face' error even after ...
Read more >
CVZone: Easy to Run Image Processing and AI Functions
from cvzone.HandTrackingModule import HandDetector import cv2 cap = cv2. ... sbOnUploaded: Status message displayed when the image has been uploaded.
Read more >
MediaPipe Hands - Google
First, we train a palm detector instead of a hand detector, ... Using a regular cross entropy loss and no decoder gives a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found