Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

showing error in making gestures #19

Open
himanshu3897 opened this issue Sep 26, 2019 · 5 comments
Open

showing error in making gestures #19

himanshu3897 opened this issue Sep 26, 2019 · 5 comments

Comments

@himanshu3897
Copy link

cv2.error: OpenCV(4.1.1) C:\projects\opencv-python\opencv\modules\imgproc\src\shapedescr.cpp:274:

@himanshu3897
Copy link
Author

gesture folder are made but cant save any image over that

@mM-009
Copy link

mM-009 commented Oct 12, 2019

The problem related to not being able to run CreateGest.py is due different versions of OpenCV as cv2.findContours() has varying return signatures in OpenCV 3.4.X, OpenCV 2.X and 4.1.X.

using the code below

contours = cv2.findContours(thresh.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
 contours = contours[0] if len(contours) == 2 else contours[1]

instead of

contours = cv2.findContours(thresh.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE) [1]

runs CreateGest.py and saves 1200 images in the folder. However, the images are still not generating good hand contours.

I am using opencv-contrib-python==4.1.1.26

@akshaybahadur21 which opencv version did you use in this project ?

@mM-009
Copy link

mM-009 commented Oct 12, 2019

anyway, the above method in opencv == 4.1.1.26 had contour problem as it was finding black object from white background. This is incorrect because in OpenCV, object to be found should be white and background should be black. So the image needs to be inverted using THRESH_BINARY_INV as shown below:

ret, thresh = cv2.threshold(opening, 30, 255, cv2.THRESH_BINARY_INV)

instead of :

ret, thresh = cv2.threshold(opening, 30, 255, cv2.THRESH_BINARY)

so the code after all changes is :

      # ret, thresh = cv2.threshold(opening, 30, 255, cv2.THRESH_BINARY)
        ret, thresh = cv2.threshold(opening, 30, 255, cv2.THRESH_BINARY_INV)
        thresh = thresh[y:y + h, x:x + w]
        #contours = cv2.findContours(thresh.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)[1]
        contours = cv2.findContours(thresh.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
        contours = contours[0] if len(contours) == 2 else contours[1]

CreateGest.py runs correctly using above changes in code for opencv version 4.1.1.26

@pradeep42375
Copy link

It is still not creating the gestures

@sohanatarafder99
Copy link

my create gesture file is completely working but it is not saving the images

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants