mahaveerverma / hand-gesture-recognition-opencv

A project on hand detection and hand gesture recognition developed using OpenCV on Python 2.7.
MIT License
319 stars 132 forks source link

To generate a background model when I press b it exits and error occurs in line 232 ie "bg_model = cv2.BackgroundSubtractorMOG2(0,10) " ie Attribute error: 'module' object has no attribute 'BackgroundSubtractorMOG2' #2

Closed anuvava closed 6 years ago

mahaveerverma commented 7 years ago

Please use OpenCV2.4.8 for this project. Or else you'll have to modify that line for OpenCV3.0 onwards to use cv2.BackgroundSubtractorMOG instead of cv2.BackgroundSubtractorMOG2. Refer the documentation for the same for your specific OpenCV version.

I'd suggest using OpenCV2.4.8 or if you don't want to downgrade from your current OpenCV version, you can use 'virtual environment' and setup OpenCV2.4.8 exclusively for this project there.

anuvava commented 7 years ago

Sir I modify the line but the same error occurs. I already installed opencv 3.0.1 and python 2.7.6 on ubuntu 14.0.1. So Is it possible to install opencv 2.4.8 on system? How can I use virtual environment and setup opencv2.4.8.? Is there any problem occur if I use use virtual environment along with the already downloaded version?

mahaveerverma commented 7 years ago

I would suggest to use virtual environment. A virtual environment does this exact task of creating a virtual new workspace for your codes in which you can install a different version of any library and it won't affect your existing installations.

Here is a tutorial on using virtualenv: http://docs.python-guide.org/en/latest/dev/virtualenvs/

Here, once you activate your virtual environment, python will be automatically setup in it. Then just install opencv2.4.8 normally in your virtual environment. Installing any packages inside the env won't interfere with any other existing package from the host system.

Ankur-prasun commented 7 years ago

change it to cv2.createBackgroundSubtractorMOG2(0,10) and it will work. for more info run the command help(cv2) in python console

anuvava commented 7 years ago

Sir, Thanks. It works.But there occurs another error. To capture maximum range of shades of hand when press c it exit and an error displays.

In line 207 :contours,hierarchy=cv2.findContours(contour_frame,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)

"value error:too many values to unpack".

How to resolve this error ?

On Wed, Mar 1, 2017 at 11:36 PM, Ankur-prasun notifications@github.com wrote:

change it to cv2.createBackgroundSubtractorMOG2(0,10) and it will work. for more info run the command help(cv2) in python console

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mahaveerverma/hand-gesture-recognition-opencv/issues/2#issuecomment-283420288, or mute the thread https://github.com/notifications/unsubscribe-auth/AY0b2duJejrmEfYNI7xg2003DPyqZlJwks5rhbO2gaJpZM4MN_eu .

Ankur-prasun commented 7 years ago

Change it to _,contours,hierarchy=cv2.findContours(contour_frame,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)

anuvava commented 7 years ago

Sir,

Thanks a lot...

After doing it no error....Well done sir...Again Thanks a lot for your contribution...

On Thu, Mar 2, 2017 at 11:26 AM, Ankur-prasun notifications@github.com wrote:

Change it to _,contours,hierarchy=cv2.findContours(contour_frame, cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mahaveerverma/hand-gesture-recognition-opencv/issues/2#issuecomment-283564002, or mute the thread https://github.com/notifications/unsubscribe-auth/AY0b2e-D8IjtYLeSs8lMzUzpH9s6gL4oks5rhloHgaJpZM4MN_eu .

Ankur-prasun commented 7 years ago

anuvava Have you solved the issue of hand gesture dictionary which i have raised? kindly let me know

anuvava commented 7 years ago

I also have the same problem.Gestures not detected properly as shown in the documentation.

On Thu, Mar 2, 2017 at 1:28 PM, Ankur-prasun notifications@github.com wrote:

anuvava Have you solved the issue of hand gesture dictionary which i have raised? kindly let me know

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mahaveerverma/hand-gesture-recognition-opencv/issues/2#issuecomment-283582734, or mute the thread https://github.com/notifications/unsubscribe-auth/AY0b2UiX_zGzTS6uQmCtK6x67m-nILtAks5rhnaMgaJpZM4MN_eu .

mahaveerverma commented 7 years ago

Thanks for the help @Ankur-prasun . And @anuvava, for improving efficiency, I would suggest redefining dictionary definitions. I've tried explaining the part on how to read dimensions in the other 'issue'. Please refer that.

anuvava commented 7 years ago

Sir, Can you publish the modified code for deciding hand radius and finger positions, such that it prints these parameters at all times whenever any hand is shown to it. .. So that I can recognize the hand radius and finger positions of my hand and modify the dimensions in GestureAPI.py . Can you please help me sir?

anuvava commented 7 years ago

Sir,

I read your documentation.I have some doubts regarding the concepts.

First hand histogram is created.After that whether create a histogram for frame? How can we searching for hand using the already histogram generated? when I add these lines the histogram and contour displayed like this.Is the displayed histograms and contour is correct? cv2.imshow('contour', found) cv2.imshow('histogram', hand_hist)

What are the algorithms or techniques used for contour,convex hull technically?

On Thu, Mar 2, 2017 at 8:29 PM, Mahaveer Verma notifications@github.com wrote:

Thanks for the help @Ankur-prasun https://github.com/Ankur-prasun . And @anuvava https://github.com/anuvava, for improving efficiency, I would suggest redefining dictionary definitions. I've tried explaining the part on how to read dimensions in the other 'issue'. Please refer that.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mahaveerverma/hand-gesture-recognition-opencv/issues/2#issuecomment-283676305, or mute the thread https://github.com/notifications/unsubscribe-auth/AY0b2QXY8Jj3dYjZY1sKgdJ58vMIzJ3Qks5rhtlLgaJpZM4MN_eu .

anuvava commented 7 years ago

Sir,

Can you please explain what method is used to identify the finger tips.? Can you specify the algorithm used for the fingertip detection.?I refer many documents.But I could not understand properly.Please reply to this mail.

On Wed, Mar 29, 2017 at 4:23 PM, Anu Pd anupdais@gmail.com wrote:

Sir,

I read your documentation.I have some doubts regarding the concepts.

First hand histogram is created.After that whether create a histogram for frame? How can we searching for hand using the already histogram generated? when I add these lines the histogram and contour displayed like this.Is the displayed histograms and contour is correct? cv2.imshow('contour', found) cv2.imshow('histogram', hand_hist)

What are the algorithms or techniques used for contour,convex hull technically?

On Thu, Mar 2, 2017 at 8:29 PM, Mahaveer Verma notifications@github.com wrote:

Thanks for the help @Ankur-prasun https://github.com/Ankur-prasun . And @anuvava https://github.com/anuvava, for improving efficiency, I would suggest redefining dictionary definitions. I've tried explaining the part on how to read dimensions in the other 'issue'. Please refer that.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mahaveerverma/hand-gesture-recognition-opencv/issues/2#issuecomment-283676305, or mute the thread https://github.com/notifications/unsubscribe-auth/AY0b2QXY8Jj3dYjZY1sKgdJ58vMIzJ3Qks5rhtlLgaJpZM4MN_eu .

sweden009 commented 7 years ago

line 40, in hand_capture for i in xrange(capture_box_count): NameError: name 'xrange' is not defined

what should i do please help

ghost commented 6 years ago

Can you share the link to the whl of openCV 2.4.8 ?

guillaumesoul commented 6 years ago

@sweden009 : try change everywhere xrange function is used by range

mahaveerverma commented 6 years ago

@amandeepsinghkhanna You can get the full setup from https://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.10/

You need only C:\opencv\build\python\x86\2.4.10\cv2.pyd (the folder structure might be a little different). Copy that to C:\Python27\Lib\site-packages\