Open its-Yogesh opened 2 years ago
me too
Hello!
Maybe try
from cvzone.HandTrackingModule import HandDetector
and do
detector = HandDetector(detectionCon=0.0, maxHands=1)
Thanks for you Advice but still it shows the same error.
On Fri, 26 Nov 2021, 7:00 pm François Schwarzentruber, < @.***> wrote:
Hello! Maybe try from cvzone.HandTrackingModule import HandDetector and do detector = HandDetector(detectionCon=0.0, maxHands=1)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cvzone/cvzone/issues/21#issuecomment-979979893, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARISI7J3QI2YA4M3H7VJOITUN6DW5ANCNFSM5IP7SLYQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
I have the same error
Make sure mediapipe is installed. Try: import cv2 from cvzone.HandTrackingModule import HandDetector
cap = cv2.VideoCapture(0) cap.set(3, 1280) cap.set(4, 720) detector = HandDetector(detectionCon=0.8, maxHands=1)
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:
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()
Thanks! @Mandizvidzafn But when I set maxHands to 2, It gives me an Error!
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
Traceback (most recent call last):
File "/home/alikhorshidi/PycharmProjects/GestureRobotArmControl/GestureControlArm.py", line 34, in
It works thanks to @Mandizvidzafn
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
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()
hi everyone i.m getting this problem
hands, img = detector.findHands(img, draw=True)
ValueError: too many values to unpack (expected 2)
ishlab chiqarish misol kodini ishga tushirishga harakat qildim. lekin menda Atribut xatosi bor
use 1.4.1 version of cvzone
AttributeError: "cvzone" modulida "HandDetector" atributi yo'q.
Bu muammoni hal qilishimga yordam bering.
misol kodi.
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)
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:
success, img = cap.read()
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()
Can we use mediapipe , cvzone for mobile aplication?
probably can't
@.*** | |
---|---|
@.*** |
---- Replied Message ---- | From | Tiran @.> | | Date | 12/25/2022 01:43 | | To | @.> | | Cc | @.>@.> | | Subject | Re: [cvzone/cvzone] 'cvzone' has no attribute 'HandDetector' (Issue #21) |
Can we use mediapipe , cvzone for mobile aplication?
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
Of cource no!
from cvzone.HandTrackingModule import HandDetector put this line when your import/calling your libraries. then check if it works. this worked for me
Mine could work, check wether have you downloaded the mediapipe, or you can change a version of cvzone. Wish you the best.
@.*** | |
---|---|
@.*** |
---- Replied Message ---- | From | @.> | | Date | 08/23/2023 08:14 | | To | @.> | | Cc | @.>@.> | | Subject | Re: [cvzone/cvzone] 'cvzone' has no attribute 'HandDetector' (Issue #21) |
from cvzone.HandTrackingModule import HandDetector put this line when your import/calling your libraries. then check if it works. this worked for me
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
cvzone version 1.5.6
from cvzone.HandTrackingModule import HandDetector
detector=HandDetector(detectionCon=0.8, maxHands=2)
error: Invoked:0.8 something error occur
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()
There's a small modification, since while calculating it accepts 3 values hence the updated code should be:
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()
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.