mahaveerverma / hand-gesture-recognition-opencv

A project on hand detection and hand gesture recognition developed using OpenCV on Python 2.7.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ValueError: too many values to unpack

xtremecreative opened this issue · comments

while executing the program after pressing b and then c this error is coming

Traceback (most recent call last):
File "HandRecognition.py", line 207, in
contours,hierarchy=cv2.findContours(contour_frame,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
ValueError: too many values to unpack

and the bounding boxes being displayed like this as per image bellow

I am very much new to all these things Kindly guide me further

sc_001

Seems like you are using opencv version 3+
Change the line
contours,hierarchy=cv2.findContours(contour_frame,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
to
_ ,contours, hierarchy=cv2.findContours(contour_frame,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
the new findContours function returns 3 values.

Thanks sulphurgfx its really solved the problem !!!!