I'm doing finger detection i.e. the fingertips using VGA camera. I have used HSV and image thresholding and I am able to detect the fingertips.
The Problem: I can now find the centroid of the white spot in a black and white image if there is only one white spot (if I place just one finger); but if I place multiple fingers more white spots will come in the final image. So I want to find each centroid separately.
I want to find all centroids of each of the white spots i.e. if I place more than one finger in front of the camera. Look at the code below
thresholded_img = cv.CreateImage(cv.GetSize(hsv_img), 8, 1)
cv.InRangeS(hsv_img, (0,0,200), (0,0,255), thresholded_img)
moments = cv.Moments(cv.GetMat(thresholded_img,1), 0)
area = cv.GetCentralMoment(moments, 0, 0)
x = cv.GetSpatialMoment(moments, 1, 0)/area
y = cv.GetSpatialMoment(moments, 0, 1)/area
posY=y
posX=x
Here thresholded_img
is a black and white image where the fingertips alone is represented as white and all other in black.
In this code if the thresholded_img
contains a single white spot then I can get the x
and y
coordinates of the centroid of that dot correctly!
But how to find centroid of each white dots in this image?
But if there is multiple white dots in the thresholded image then it's finding wrong centroid!
How can I change the above code to find (x,y coordinates) separate centroid of each white dots in a single frame (image)?
Refer this image please. http://www.csksoft.net/data/pic/laserkbd/036.jpg