Recently i was studying Emgu, but find there is a bug in the VoteForUniqueness function in class Features2DToolbox.

The idea of "VoteForUniqueness" is to filter ambiguous matchings. Lets say you want to match the points of image A with the points of image B.

Here is how it works :

  • "KnnMatch" is looking for 2-Nearest Neighbor for each point of image A in image B.
  • In image B, if the 1st and 2nd neighbors are too similar (the distance ratio is less than 0.8), we consider that we don't know which one is the best matching, so the matching is filtered (deleted).

Be awarded that here, when we speak about nearest neighbor and distance, we talk about the distance between the features of points (not the position).

According to the functionality of VoteForUniqueness, we need to fix a bug inside the function.

When the n ratio of earest and the 2nd nearest is larger than the threshold, which means they are two similar, we need to remove that match by mask them out.

/// <summary>
/// Filter the matched Features, such that if a match is not unique, it is rejected.
/// </summary>
/// <param name="uniquenessThreshold">The distance different ratio which a match is consider unique, a good number will be 0.8</param>
/// <param name="mask">This is both input and output. This matrix indicates which row is valid for the matches.</param>
/// <param name="matches">Matches. Each matches[i] is k or less matches for the same query descriptor.</param>
public static void VoteForUniqueness(VectorOfVectorOfDMatch matches, double uniquenessThreshold, Mat mask)
{
MDMatch[][] mArr = matches.ToArrayOfArray();
byte[] maskData = new byte[mArr.Length];
GCHandle maskHandle = GCHandle.Alloc(maskData, GCHandleType.Pinned);
using (Mat m = new Mat(mArr.Length, , DepthType.Cv8U, , maskHandle.AddrOfPinnedObject(), ))
{
mask.CopyTo(m);
for (int i = ; i < mArr.Length; i++)
{
//Origianlly is mArr[i][0].Distance / mArr[i][1].Distance) < uniquenessThreshold
if (maskData[i] != && (mArr[i][].Distance / mArr[i][].Distance) >= uniquenessThreshold)
{
maskData[i] = (byte);  //if the distance is too similiar, then elimilate the feature by set mask to 0
}
} m.CopyTo(mask);
}
maskHandle.Free();
}

Study Emgu VoteForUniqueness的更多相关文章

  1. Improve Your Study Habits

    1.Plan your time carefully. Make a list of your weekly tasks.Then make a schedule or chart of your t ...

  2. 基于Emgu CV的人脸检测代码

    这个提供的代码例子是Emgu CV提供的源码里面自带的例子,很好用,基本不需要改,代码做的是人脸检测不是人脸识别,这个要分清楚.再就是新版本的Emgu CV可能会遇到系统32位和64位处理方式有区别的 ...

  3. 自己积累的一些Emgu CV代码(主要有图片格式转换,图片裁剪,图片翻转,图片旋转和图片平移等功能)

    using System; using System.Drawing; using Emgu.CV; using Emgu.CV.CvEnum; using Emgu.CV.Structure; na ...

  4. Emgu.CV 播放视频

    using Emgu.CV; using System; using System.Drawing; using System.Threading; using System.Windows.Form ...

  5. Emgu.CV/opencv 绘图 线面文字包括中文

    绘图很简单 Emgu.CV.Image<Bgr, Byte> image;   使用image.Draw可以画各种图形和文字包括英文及数字,不支持中文   CircleF circle = ...

  6. yuv420p转为emgucv的图像格式Emgu.CV.Image<Bgr, Byte>

    GCHandle handle = GCHandle.Alloc(yuvs, GCHandleType.Pinned); Emgu.CV.Image<Bgr, Byte> image = ...

  7. "Emgu.CV.CvInvoke”的类型初始值设定项引发异常 解决办法

    系统win7 32位,只在这一台电脑上出现这种问题,已知VS编译是X86,在数台电脑上测试都正常. 后来把opencv的dll路径例如 E:\...\x86  加入到系统环境变量中就正常了. emgu ...

  8. EmguCV控件Emgu.CV.UI.ImageBox及C# picturebox显示图片连续刷新出现闪烁问题

    在上一篇里,EmguCV(OpenCV)实现高效显示汉字及叠加  实现了视频叠加及显示,但存在问题,就是 Emgu.CV.UI.ImageBox及C# picturebox显示图片时都会出现闪烁,尤其 ...

  9. Emgu学习手册

    作为opencv的c#封装库.emgu可以满足基本的图像处理功能,经过测试,效果还可以,主要用于windows窗体应用程序的开发,或者wpf,你可以用来做ocr,也可以用来做人脸识别或者可以用来做定位 ...

随机推荐

  1. xcode armv6 armv7 armv7s arm64

    目前ios的指令集有以下几种: armv6 iPhone iPhone2 iPhone3G 第一代和第二代iPod Touch armv7 iPhone4 iPhone4S armv7s iPhone ...

  2. [转]Redis实现分析

    Redis实现分析 浏览次数:1018次 KITERUNNER_T 2014年10月19日 字号: 大 中 小 分享到: QQ空间 新浪微博 腾讯微博 人人网 豆瓣网 开心网 更多 1   1 环境准 ...

  3. 一种Go使用tcp检测超时的方式

    c.SetReadDeadline(time.Now()) if _, err := c.Read(one); err == io.EOF { l.Printf(logger.LevelDebug, ...

  4. for循环相关

    循环语句是指令式编程的常见语句,Scala对其加以改进,成为适应函数式风格的利器. for循环中的变量,没有val或者var,是因为变量的类型,完全是集合中的元素的类型.作用域持续到括号结束. 在sc ...

  5. 关于Mac下的SSH客户端iterm2等配置

    linux后台开发的同学们晓得,在windows下有xshell\securecrt这样优秀的ssh客户端软件.mac下查找了下,有securecrt mac版,网上也有破解的,试用了一段时间,一个问 ...

  6. mactype支持qq浏览器

    win7上使用mactype之后qq浏览器网页显示的字体不清晰,颜色也比较浅.解决方法: 1. 再qq浏览器地址栏中输入:qqbrowser://flags 2.在设置中启用DirectWrite高清 ...

  7. python学习之路(一)屌丝逆袭之路

    变量                                                                                                  ...

  8. JSBinding+SharpKit / JavaScript调试

    注意: 1 Firefox 的版本用41 2 我发现调试很难用的,现在我都用打印 步骤参考图:

  9. 使用as3控制动画的播放与暂停

    1.需要两个按钮元件 2.在属性面板为两个按钮元件分别命名为pausebutton与playButton 3.代码 stop(); pausebutton.visible = false; playB ...

  10. 高度平衡的二叉搜索树(AVL树)

    AVL树的基本概念 AVL树是一种高度平衡的(height balanced)二叉搜索树:对每一个结点x,x的左子树与右子树的高度差(平衡因子)至多为1. 有人也许要问:为什么要有AVL树呢?它有什么 ...