I am using the OpenCV library for an image processing project to detect hands. I initialized the image in iplimage
, colored it, and then converted it to HSV with cvCvtColor(imageHand,imageHand,CV_BGR2HSV );
I don't know the efficient algorithm so that's my problem. Please check my code:
for( int row = 0; row < imageHand->height; row++ )
{
for ( int col = 0; col < imageHand->width; col++ )
{
h =(imageHand->imageData[imageHand->widthStep * row + col * 3]) ;
s = (imageHand->imageData[imageHand->widthStep * row + col * 3 + 1]);
v = (imageHand->imageData[imageHand->widthStep * row + col * 3 + 2]);
if( h>85)
{
imageHand->imageData[imageHand->widthStep * row + col * 3 ] = 0 ;
imageHand->imageData[imageHand->widthStep * row + col * 3 + 1 ] =0 ;
imageHand->imageData[imageHand->widthStep * row + col * 3 + 2 ] = 0 ;
}
else
{
imageHand->imageData[imageHand->widthStep * row + col * 3 ] = 255 ;
imageHand->imageData[imageHand->widthStep * row + col * 3 + 1 ] = 255 ;
imageHand->imageData[imageHand->widthStep * row + col * 3 + 2 ] = 255 ;
}
}
}
I think the range of the searched h
is > 85
!?
If you know a better algorithm than please guide me.
Best Answer
If you take a look at this site, Hand detection using opencv, you'll find a similar algorithm to what you're using. I would say that the easiest way of detecting a hand would be through the use of colour (i.e. skin detection). I would definitely recommend looking at the algorithm provided by that site first. There's another part that also goes into gesture recognition, if that's an eventual problem you're going to need to handle.
Other possibilities include: