简体   繁体   English

用opencv python检测复杂的形状

[英]Detecting complex shapes with opencv python

I'm working on a project where I need to be able to see the difference between all 4 playing card symbols: heart, spade, diamond and club in real-time.我正在做一个项目,我需要能够实时查看所有 4 种扑克牌符号之间的区别:心形、黑桃、菱形和俱乐部。 This means that the angle, lighting, and distance to the symbol(s) constantly change (and therefore detecting objects based on contour area won't be an option).这意味着角度、光照和与符号的距离不断变化(因此无法选择基于轮廓区域检测对象)。

So when I hold a heart symbol in front of my camera I'm trying to draw the word 'heart' inside it.所以当我在我的相机前拿着一个心形符号时,我试图在里面画出“心”这个词。 if I do the same with a spade, I want it to write "spade", etc.如果我用黑桃做同样的事情,我希望它写“黑桃”等。

I have tried doing this in various different ways, but all attempts failed or didn't work as good as I want it to.我尝试过以各种不同的方式执行此操作,但所有尝试都失败了或没有达到我想要的效果。

The methods I've tried:我试过的方法:

  • haarcascades Haarcascades
  • template matching, doesn't work due to the rotations that are possible模板匹配,由于可能的旋转而不起作用
  • color detection, which only does half the job since there are 2 symbols per color颜色检测,由于每种颜色有 2 个符号,因此只能完成一半的工作
  • feature matching: this tutorial doesn't work because the symbols don't have enough detail to find the keypoints特征匹配: 本教程不起作用,因为符号没有足够的细节来找到关键点

I can add source codes of these attempts if needed, but I don't think it will add any value, since they didn't really get me anywhere.如果需要,我可以添加这些尝试的源代码,但我认为它不会增加任何价值,因为它们并没有真正让我在任何地方。

The Images I'm using:我正在使用的图像:

在此处输入图片说明

Since you're dealing with relative low complex symbols why don't you try contour match shaping?既然您正在处理相对低复杂度的符号,为什么不尝试轮廓匹配整形呢? You might have to adapt to some more complex cases but I think that could be a first good approach:您可能需要适应一些更复杂的情况,但我认为这可能是第一个好方法:

Contours : More Functions 轮廓:更多功能

Structural Analysis and Shape Descriptors 结构分析和形状描述符

Remember that you also have the color information to use in your app.请记住,您还有要在应用程序中使用的颜色信息。 Anyway, also take a look at this .无论如何,也看看这个

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

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