Study Emgu VoteForUniqueness
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的更多相关文章
- 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 ...
- 基于Emgu CV的人脸检测代码
这个提供的代码例子是Emgu CV提供的源码里面自带的例子,很好用,基本不需要改,代码做的是人脸检测不是人脸识别,这个要分清楚.再就是新版本的Emgu CV可能会遇到系统32位和64位处理方式有区别的 ...
- 自己积累的一些Emgu CV代码(主要有图片格式转换,图片裁剪,图片翻转,图片旋转和图片平移等功能)
using System; using System.Drawing; using Emgu.CV; using Emgu.CV.CvEnum; using Emgu.CV.Structure; na ...
- Emgu.CV 播放视频
using Emgu.CV; using System; using System.Drawing; using System.Threading; using System.Windows.Form ...
- Emgu.CV/opencv 绘图 线面文字包括中文
绘图很简单 Emgu.CV.Image<Bgr, Byte> image; 使用image.Draw可以画各种图形和文字包括英文及数字,不支持中文 CircleF circle = ...
- yuv420p转为emgucv的图像格式Emgu.CV.Image<Bgr, Byte>
GCHandle handle = GCHandle.Alloc(yuvs, GCHandleType.Pinned); Emgu.CV.Image<Bgr, Byte> image = ...
- "Emgu.CV.CvInvoke”的类型初始值设定项引发异常 解决办法
系统win7 32位,只在这一台电脑上出现这种问题,已知VS编译是X86,在数台电脑上测试都正常. 后来把opencv的dll路径例如 E:\...\x86 加入到系统环境变量中就正常了. emgu ...
- EmguCV控件Emgu.CV.UI.ImageBox及C# picturebox显示图片连续刷新出现闪烁问题
在上一篇里,EmguCV(OpenCV)实现高效显示汉字及叠加 实现了视频叠加及显示,但存在问题,就是 Emgu.CV.UI.ImageBox及C# picturebox显示图片时都会出现闪烁,尤其 ...
- Emgu学习手册
作为opencv的c#封装库.emgu可以满足基本的图像处理功能,经过测试,效果还可以,主要用于windows窗体应用程序的开发,或者wpf,你可以用来做ocr,也可以用来做人脸识别或者可以用来做定位 ...
随机推荐
- HDU 5876 (大连网赛1009)(BFS + set)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5876 题意:给定一个图(n个顶点m条边),求其补图最短路 思路:集合a表示当前还未寻找到的点,集合b表 ...
- webpack脚手架搭建(简单版)
运行命令 安装依赖:npm install 运行项目:npm start 大致流程 npm init:新建 package.json 将需要的依赖模块加入 dependencies(生产环境) 和 d ...
- ListView中itemz中控件的点击事件和条目点击事件冲突
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...
- mm/mmap.c
/* * linux/mm/mmap.c * * Written by obz. */#include <linux/stat.h>#include <linux/sched. ...
- svn使用(三)
使用VisualSVN服务端,把已有的文件导入到服务端中 可以按以下步骤:
- 知识积累:CGI,FastCGI,PHP-CGI与PHP-FPM
CGICGI全称是“公共网关接口”(Common Gateway Interface),HTTP服务器与你的或其它机器上的程序进行“交谈”的一种工具,其程序须运行在网络服务器上.CGI可以用任何一种语 ...
- nodejs-基本语法
初识nodejs-基本语法 nodejs是JavaScript的一个在后端的运行环境,关于nodejs的认识,我们可以看上一篇文章<<初识nodejs>>,我们要使用nodej ...
- Spring中的ApplicationContext事件机制
ApplicationContext的事件机制是观察者设计模式的实现,通过ApplicationEvent类和ApplicationListerner接口来实现. 1. 创建EmailEvent pu ...
- ADF_Data Binding系列1_使用Bean Data Control
2015-02-16 Created By BaoXinjian
- Yii里增删改查的操作方法
一.AR $model=New user();//user是数据库中的一张表,有id,name,pwd字段 1.增加: <1. $model->name='张三': $model-> ...