DEV Community

Discussion on: Finger Detection and Tracking using OpenCV and Python

Collapse
 
tungts1101 profile image
tungts1101

Got this error after I pressed 'z' key:

Traceback (most recent call last):
File "FingerDetection.py", line 186, in
main()
File "FingerDetection.py", line 171, in main
manage_image_opr(frame, hand_hist)
File "FingerDetection.py", line 136, in manage_image_opr
contour_list = contours(hist_mask_image)
File "FingerDetection.py", line 23, in contours
_, cont, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
ValueError: not enough values to unpack (expected 3, got 2)

Do you have any idea?

Collapse
 
amarlearning profile image
Amar Prakash Pandey

@tungts1101 I will suggest you use opencv-python version 3.4.*. You are facing this issue because you are using some higher version of opencv-python.

You can download the correct dependencies using requirement.txt file present in the repository.

Hint: Use command sudo pip install -r requirement.txt

Collapse
 
tungts1101 profile image
tungts1101

That's work. But I think there's still something need to be done in order to eliminate noise in background.

Thread Thread
 
amarlearning profile image
Amar Prakash Pandey

Yes, that's an issue. You can take that up if you want.

Collapse
 
databits profile image
Mitch

Update this line...
From:
_, cont, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

To:
cont, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

That should fix the issue for CV 4.5

Collapse
 
mrcomnguoi profile image
MrComNguoi

Thank you, it works

Some comments have been hidden by the post's author - find out more