简体   繁体   English

使用OpenCV比较两个图像

[英]compare two images using OpenCV

I want to compare two images using OpenCV. 我想用OpenCV比较两个图像。 Could I filter the nearest matching result among other training data set..? 我可以在其他训练数据集中过滤最近的匹配结果吗?
Example : the Database containing training image which show number 5 in using one hand. 示例:包含训练图像的数据库,单手显示数字5。

Is it possible to match someone else ,same sign with that training image..? 是否可以匹配其他人,与该训练图像相同的标志..? Using OpenCV. 使用OpenCV。 Please help me. 请帮我。

Like sinelaw said, there is no straightforward, easy solution in general . 就像sinelaw说,有一般没有直接的,简单的解决方案。

However, I can think of one simple way that would work for your specific example . 但是,我可以想出一个适用于您的具体示例的简单方法。

  • Detect areas corresponding to human skin in the image. 检测与图像中的人体皮肤相对应的区域。 This is assuming the person isn't wearing gloves (if they are, knowing the color of the gloves will help). 这是假设该人没有戴手套(如果他们是,知道手套的颜色会有帮助)。 See this example on skin detection. 请参阅皮肤检测示例 Basically, you convert your image into YUV and threshold using the chrominance, because it is known that human skin occupies only a small part of the chroma spectrum, regardless of race 基本上,您使用色度将图像转换为YUV和阈值,因为众所周知,无论种族如何,人类皮肤仅占色度谱的一小部分
  • Detect contours. 检测轮廓。 In OpenCV, this is done using cvFindContours function. 在OpenCV中,这是使用cvFindContours函数完成的。 Here's an example of that function being used to find ellipses. 这是用于查找省略号的函数的示例 You're interested in contours of any shape, not just ellipses at this point. 你对任何形状的轮廓感兴趣,而不仅仅是椭圆形。
  • Now, go through all your contours, and look for a contour that looks like an open hand making the 5 signal. 现在,浏览所有轮廓,并寻找一个看起来像一个开放的手制作5信号的轮廓。 This isn't as hard as this sounds, because you're after a convex hull (red outline) with a 4-5 convexity defects (the black arrows): 这并不像听起来那么难,因为你是一个凸出的船体(红色轮廓),有4-5个凸起缺陷(黑色箭头):

凸性缺陷

  • The image above is from the OpenCV API description of cvConvexityDefects function. 上图来自cvConvexityDefects函数的OpenCV API描述。 Go read its description for information about how it's used. 阅读其描述以获取有关其使用方式的信息。
  • Once you have the convex hull, check the size of the defects. 一旦你有凸壳,检查缺陷的大小。 4 of them should be approximately the same size (cause the fingers are the same length). 其中4个应大致相同(因为手指的长度相同)。 If that's the case, you have your open hand giving you a high five. 如果是这样的话,那么你可以用张开的手给你一个高五。

请参阅我对这个问题的回答 - 没有直接,简单的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM