Skip to content

Commit

Permalink
Merge pull request #32 from harshmittal2210/patch-1
Browse files Browse the repository at this point in the history
Corrected cv2.findContours
  • Loading branch information
EvilPort2 authored Aug 7, 2019
2 parents 7af50aa + 6e63c8f commit df1d624
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion recognize_gesture.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ def recognize():
thresh = cv2.merge((thresh,thresh,thresh))
thresh = cv2.cvtColor(thresh, cv2.COLOR_BGR2GRAY)
thresh = thresh[y:y+h, x:x+w]
contours = cv2.findContours(thresh.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)[0]
(openCV_ver,_,__) = cv2.__version__.split(".")
if openCV_ver=='3':
contours = cv2.findContours(thresh.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)[1]
elif openCV_ver=='4':
contours = cv2.findContours(thresh.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)[0]
if len(contours) > 0:
contour = max(contours, key = cv2.contourArea)
#print(cv2.contourArea(contour))
Expand Down

0 comments on commit df1d624

Please sign in to comment.