使用OpenCV进行手检测

Moh*_*mal 8 c++ opencv image-processing computer-vision

我正在使用OpenCV库来检测手部的图像处理项目.我初始化图像iplimage,着色它,然后将其转换为HSV,cvCvtColor(imageHand,imageHand,CV_BGR2HSV ); 我不知道有效的算法,所以这是我的问题.请检查我的代码:

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 ;

         }


     }
}
Run Code Online (Sandbox Code Playgroud)

我认为搜索的范围h> 85!?如果你知道一个更好的算法,请指导我.

小智 6

如果你看看这个网站,使用opencv进行手动检测,你会发现一个类似于你正在使用的算法.我会说,检测手的最简单方法是使用颜色(即皮肤检测).我肯定会建议先查看该网站提供的算法.还有另一个部分也会用于手势识别,如果这是您将需要处理的最终问题.

其他可能性包括:

  • 背景减法
    • 这非常简单,容易破裂,特别是如果你计划改变背景.但是,如果你只想在白墙前使用它......这可能是一种简单的方法.
  • 形状分析
    • 使用广义霍夫变换检测指尖已经取得了一些成功.假阳性可能会成为一种担忧,但效率是一种担忧,特别是在具有大量背景的情况下.