ValueError: too many values to unpack (expected 2) · Issue #78 · cvzone/cvzone · GitHub
Skip to content

ValueError: too many values to unpack (expected 2) #78

Open

Description

@M3M0Ri

i have problem with HandTrackingModule in apple M1

WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1709540722.925530 1 gl_context.cc:344] GL version: 2.1 (2.1 Metal - 83), renderer: Apple M1
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
Total MCQ Objects Created: 4
Traceback (most recent call last):
File "/Users/Desktop/pythonProject/main.py", line 66, in
length, info = detector.findDistance(lmList[8], lmList[12])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/CV/lib/python3.11/site-packages/cvzone/HandTrackingModule.py", line 146, in findDistance
x1, y1 = p1
^^^^^^
ValueError: too many values to unpack (expected 2)

Activity

  1. sb-git-cs commented on May 5, 2024

    @sb-git-cs
    from cvzone.HandTrackingModule import HandDetector
    import cv2
    
    cap = cv2.VideoCapture(0)
    detector = HandDetector(detectionCon=0.8, maxHands=1)
    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
                # Now you see that in findDistance, x1,y1 = p1 , this will give you error since x1, y1, z1 = p # It should be like this
                 length, info, img = detector.findDistance(lmList1[8][:2], lmList2[8][:2], img)
                # 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()
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions