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. UVA 247 电话圈 (floyd传递闭包 + dfs输出连通分量的点)

    题意:输出所有的环: 思路:数据比较小,用三层循环的floyd传递闭包(即两条路通为1,不通为0,如果在一个环中,环中的所有点能互相连通),输出路径用dfs,递归还没有出现过的点(vis),输出并递归 ...

  2. 初探groupcache

    groupcache是用于dl.google.com的一个memcached的替代品,相对于memcached,提供更小的功能集和更高的效率,以第三方库的形式提供服务. groupcache的常见部署 ...

  3. Ubuntu 14.04下安装Hadoop2.4.0 (单机模式)

    转自 http://www.linuxidc.com/Linux/2015-01/112370.htm 一.在Ubuntu下创建Hadoop组和hadoop用户 增加hadoop用户组,同时在该组里增 ...

  4. Sublog: 支持Markdown和语法高亮的跨平台博客客户端

    灵感来自米米饭 功能一览 为什么你应该试试用Sublog写博客 项目主页: sublog 使用方法: 本项目是一个插件,首先要安装Sublime Text 2 重命名sublog.sublime-se ...

  5. IE 11 保护模式害惨了我

    花了几乎两天,一直用IE, 就说好好的 动态域名 为什么一直不能访问.用其它浏览器一试,我哭了,都是好的.

  6. 【redis】 redis 创建集群时,Waiting for the cluster to join.... 一直等待

    redis 搭建集群时,一直join.... ./redis-trib.rb  create --replicas 1 127.0.0.1:6379 127.0.0.1:6380 127.0.0.1: ...

  7. TIOBE Index for November 2015(转载)

    原文地址:http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html November Headline: Java once a ...

  8. 修改mongodb3.0副本集用户密码遇到的坑

    最近公司对项目安全方面的问题很是重视,进行了多次各种安全漏洞的扫描,于是乎就扫到了mongodb弱口令的问题. 在项目部署初期,因为大家对这个都不是特别重视,大概是因为觉得反正是内网项目吧,所以mon ...

  9. ThinkPad E440 Ubuntu 13.1无线网卡 RTL8723BE 驱动解决办法总结

    方法一.在使用网线链接到情况下 第一步.执行下边到命令,即从github上下载驱动程序并安装 sudo apt-get install linux-headers-generic build-esse ...

  10. JavaScript基本语法

    本节和CSS语法类似,理解这些语法以后,就可以按照Bootstrap的开发规范去开发自己的各种插件了. ||和&&运算符 ||表示,如果第一个元素可以转换为true,则返回第一个元素的 ...