can't find findposition :AttributeError: 'HandDetector' object has no attribute 'findPosition'

15.5k Views Asked by At

version('cvzone')=1.5.0 the code is below:

while True:
    success, img = cap.read()
    img= detector.findHands(img)
    lmlist,_=detector.findPosition(img)

    cv2.imshow("Image", img)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()
2

There are 2 best solutions below

1
On

I did a lot of projects recently with cvzone and noticed that they recently updated the library with a critical update for their guides.

The problem: cvzone have updated their library with the HandTrackingModule on Aug 31, 2021 (you can watch the commits here) and removed the findPosition function since version 1.5.0.

The solution: downgrade the cvzone package version from 1.5.0 to 1.4.1 and it should work.

For example in Pycharm:

  1. Open your project.
  2. Go to the PyCharm menu and open Preferences tab.
  3. Search for Project:"Your Project Name" tab and open it.
  4. Click on Python Interpreter tab
  5. Double click on the cvzone libary from the list.
  6. Click on Specify version box, change it to 1.4.1 and click on Install Package.

Good luck!

enter image description here

0
On
from cvzone.HandTrackingModule import HandDetector

Put this line when you are importing/calling your libraries.