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

Finger dimensions in dictionary

Ankur-prasun opened this issue · comments

Sir,
how you have decide the hand radius and other dimensions.
V.set_palm((475,225),45)
V.set_finger_pos([(490,90),(415,105)])
I am unable to understand the above dimensions. Everything is working fine but the program is not able to detect the gesture efficiently.after capturing the histogram,the program can not find the gesture as efficient as you have shown in the screenshots.
I appreciate your reply to the earliest.

For deciding hand radius and finger positions, I modify this code such that it prints these parameters at all times whenever any hand is shown to it. Then I make the gesture I want to record in front of the webcam and manually note down the dimensions being printed. I then add those dimensions into the dictionary.

In this example, (475,225) were the coordinates of palm center as printed and 45 was the radius. (490,90) and (415,105) were the finger positions printed, this would automatically infer that 2 fingers were present in this gesture.

The same is described in detail in the documentation: https://github.com/mahaveerverma/hand-gesture-recognition-opencv/blob/master/docs/Documentation.pdf

To increase efficiency you might need to redefine the gesture dictionary with parameters suited for your hand size..

Can you explain how have you calculated your hand dimensions,the distance between camera and hand position?

Go to this function:
def mark_fingers(frame_in,hull,pt,radius)

Just before the return statement, add the following statements:
print finger
print palm

What this will do is continuously print finger positions and palm center and positions for each and every frame. "print palm" will print palm data in [(cx,cy),radius] format whereas "print finger" will print them in [(y1,x1),(y2,x2)...(yn,xn)] format

Once this modification is done, run the code and just show the gesture you want to record to your webcam, then manually read the values getting printed in console/terminal, which correspond to the most normal hand position in that gesture with your hand near enough to the camera. Make changes in the dictionary accordingly. Thus no need to calculate any dimensions, just read them from the console.

sir can u explain mark_finger function clearly

for i in range(len(hull)):
dist = np.sqrt((hull[-i][0][0] - hull[-i+1][0][0])**2 + (hull[-i][0][1] - hull[-i+1][0][1])**2)
if (dist>18):
if(j==0):
finger=[(hull[-i][0][0],hull[-i][0][1])]
else:
finger.append((hull[-i][0][0],hull[-i][0][1]))
j=j+1

Well, I know I'm very late in replying to this but anyways, let me reply. As far as I remember, this part checked for distances between each finger blob detected to see if all of them are really distinct fingers at least 18 pixels apart. If it is, it'll append the finger blob to a 'finger' list.