cvMatchShapes返回逻辑上的结果 [英] cvMatchShapes returns me result which is out of logic

查看:705
本文介绍了cvMatchShapes返回逻辑上的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是计算机视觉领域的新手。

I'm a newer in computer vision field.

我在EmguCV(OpenCV的.NET包装器)中找到了一些代码示例,我试图使用它。

I found some code examples in EmguCV(.NET wrapper for OpenCV) which I`m trying to use.

目前我正在进行三角形交通标志识别,我正在使用cvMatchShapes函数。

Currently I'm working on triangle traffic sign recognition and I'm using cvMatchShapes function.

该函数在理想情况下返回零,这意味着形状相同且数字

The function returns "zero" in ideal case, it means that the shapes are the same and the number is

如果形状相似则接近于零。

close to zero if shapes are similar.

问题是在我的情况下函数返回的结果是逻辑上的。
当函数将三角形与圆形比较时,它返回小于数字的数字,在比较两个三角形后获得

The problem is that in my case function returns me result which is out of logic. when function compares triangle with the circle, it returns figure which is less than figure, got after comparing two triangles.

这是函数我使用和图像:

Here is the function that I use and the images:

                double ratio = CvInvoke.cvMatchShapes(modelSignTraffic, trafficSign, Emgu.CV.CvEnum.CONTOURS_MATCH_TYPE.CV_CONTOURS_MATCH_I3, 0);

modelSignTraffic - 是一个模板。
在我的情况下是 -

modelSignTraffic - is a template. In my case it is -

trafficSign - 是一个应该与模板进行比较的形状。

trafficSign - is an shape that should be compared to the template.

首先进行比较形状 -

first compared shape-

第二次比较形状 -

second compared shape-

对于第一个形状,我得到的比率为0.55,对于第二个形状,我得到比率为0.61。

For the first shape I get ratio 0.55 and for the second shape I get ratio 0.61 .

如果有人能解释为什么我会得到这样不合逻辑的结果以及如何修复
呢,我将非常感激?

I would be very grateful if anybody could explain why do I get such illogical result and how I can fix it?

提前谢谢你。

推荐答案

我不明白为什么你认为这个结果不符合逻辑。您是否阅读了 CV_CONTOURS_MATCH_I3 的公式? 这是。我100%肯定如果你手动计算这个系数,你会得到相同的结果。

I don't understand why do you think that this result is not logical. Did you read formula for CV_CONTOURS_MATCH_I3? Here it is. I'm 100% sure that if you calculate this coeficient by hand you will get the same result.

顺便说一句,你必须计算轮廓的系数(形状)不适用于图像。首先检测形状,然后使用 MatchShapes

By the way you have to calculate this coeficient for contours (shapes) not for images. So firstly detect shapes and after this use MatchShapes.

更新:

您的解决方案是错误的。您必须首先分割红色,然后使用 findContours 来检测红色形状。

Your solution is wrong. You have to segment red color first and after this use findContours to detect red shapes.

这篇关于cvMatchShapes返回逻辑上的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆