C++ 使用 OpenCV 进行手部检测
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9168785/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Hand detection using OpenCV
提问by Mohamed Kamal
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:
我正在使用 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 ;
}
}
}
I think the range of the searched h
is > 85
!?
If you know a better algorithm than please guide me.
我认为搜索的范围h
是> 85
!? 如果你知道一个更好的算法,请指导我。
采纳答案by Ancallan
If you take a look at this site, Hand detection using opencv, you'll find a similar algorithmto 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.
如果您查看此站点,使用 opencv 进行手部检测,您会发现与您正在使用的算法类似的算法。我会说检测手的最简单方法是使用颜色(即皮肤检测)。我肯定会建议先查看该站点提供的算法。还有另一部分也涉及手势识别,如果这是您需要处理的最终问题。
Other possibilities include:
其他可能性包括:
- Background Subtraction
- This is very simple and prone to breaking, especially if you're planning on the background changing. But, if you're expecting to only use it in front of, say, a white wall... this could be an easy way of going about it.
- Shape Analysis
- There has been some success with detecting fingertipsusing the Generalised Hough Transform. False positives can become a worry, however and efficiency is a worry, particularly in situations with a significant amount of background.
- 背景减法
- 这非常简单且容易中断,尤其是当您计划更改背景时。但是,如果您只希望在白墙前使用它……这可能是一种简单的方法。
- 形状分析
- 使用广义霍夫变换检测指尖已经取得了一些成功。然而,误报可能会令人担忧,而效率则令人担忧,尤其是在具有大量背景的情况下。
回答by Andol Li
as Ancallanhas mentioned hand detection using opencvabove, I would like to add some more information on the topic of gesture detection. In that post the author used a method of skin colour segmentation, which has got quite good results under specific circumstances.
由于Ancallan在上面提到了使用 opencv 进行手部检测,我想添加一些有关手势检测主题的更多信息。在那篇文章中,作者使用了一种肤色分割的方法,在特定情况下得到了相当不错的结果。
a new post of hand gesture detection using openCV has been updated, in which the author used a HAAR classifier to detect closed palm, and the results are much more robust than the former ones. but need to point out that the detection objects are somehow limited as one classifier only works for one gesture.
更新了一篇使用 openCV 进行手势检测的新帖子,其中作者使用了 HAAR 分类器来检测闭合的手掌,结果比以前的要健壮得多。但需要指出检测对象在某种程度上受到限制,因为一个分类器仅适用于一种手势。