使用 OpenCV 比较两个图像

发布于 2024-10-15 08:49:23 字数 134 浏览 1 评论 0原文

我想使用 OpenCV 比较两个图像。我可以在其他训练数据集中过滤最接近的匹配结果吗?
示例:包含训练图像的数据库,其中显示使用一只手的数字 5。

是否有可能将其他人与该训练图像匹配相同的标志..? 使用 OpenCV。请帮我。

I want to compare two images using 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.

Is it possible to match someone else ,same sign with that training image..?
Using OpenCV. Please help me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

久伴你 2024-10-22 08:49:24

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

See my answer to this question - there is no straightforward, easy solution.

小情绪 2024-10-22 08:49:23

正如 sinelaw 所说,一般来说没有直接、简单的解决方案。

但是,我可以想到一种适用于您的特定示例的简单方法。

  • 检测图像中与人体皮肤相对应的区域。这是假设该人没有戴手套(如果戴手套,了解手套的颜色会有所帮助)。请参阅有关皮肤检测的此示例。基本上,您可以使用色度将图像转换为 YUV 和阈值,因为众所周知,无论种族
  • 检测轮廓如何,人类皮肤仅占据色度光谱的一小部分。在 OpenCV 中,这是使用 cvFindContours 函数完成的。这是该函数用于查找的示例省略号。此时您对任何形状的轮廓感兴趣,而不仅仅是椭圆形。
  • 现在,检查所有轮廓,寻找看起来像张开的手发出 5 信号的轮廓。这并不像听起来那么难,因为您追求的是带有 4-5 个凸面缺陷(黑色箭头)的凸包(红色轮廓):

凸缺陷

  • 上面的图片来自 OpenCV API cvConvexityDefects 函数的描述。请阅读其说明以获取有关如何使用它的信息。
  • 获得凸包后,检查缺陷的大小。其中 4 个手指的大小应大致相同(因为手指的长度相同)。如果是这样的话,你就张开双手,给你高五分。

Like sinelaw said, there is no straightforward, easy solution in general.

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
  • Detect contours. In OpenCV, this is done using cvFindContours function. 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. 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):

convexity defects

  • The image above is from the OpenCV API description of cvConvexityDefects function. 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). If that's the case, you have your open hand giving you a high five.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文