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,也可以用来做人脸识别或者可以用来做定位 ...
随机推荐
- Android 布局优化
转载自stormzhang的博客:http://stormzhang.com/android/2014/04/10/android-optimize-layout/ < include /> ...
- SQL 经典练习题
create database 练习题gouse 练习题go create table Student( Sno char(3) primary key, Sname char(8) not null ...
- Phaser开源2d引擎 html5游戏框架中文简介
功能特点(Features) 易维护代码(Easy Asset Loading) Phaser可以加载图片,音频文件,数据文件,文本文件和自动解析精灵图和纹理地图集数据(出口纹理封隔器或Flash C ...
- PRCR-1065 Failed to stop resource ora.asm 处理
在网上看到的一些关闭Oracle Grid Infrastructure教程中,很多在关闭数据后就开始关闭ASM,结果提示如下的错误. [grid@rhvm1 ~]$ srvctl stop asm ...
- python数据结构与算法——图的基本实现及迭代器
本文参考自<复杂性思考>一书的第二章,并给出这一章节里我的习题解答. (这书不到120页纸,要卖50块!!,一开始以为很厚的样子,拿回来一看,尼玛.....代码很少,给点提示,然后让读者自 ...
- Linux压缩那些事儿
tar简介 Linux的压缩命令的源文件只能有一个,这意味在压缩之前不得不先将要压缩的所有文件打包成一个包,然后再压缩包,这样来完成对多个文件的压缩.所以在了解解压缩之前就必须先了解打包命令. Lin ...
- Jena Fuseki 102
Version Fuseki v1 Fuseki v2 since Jena 2.13.0 Both v1 and v2 are active and maintained.[2015/06/29] ...
- Appium 解决不能输入中文字符问题
只需在初始化driver方法时,写这两行代码即可: capabilities.setCapability("unicodeKeyboard", "True" ...
- mm/makefile
## Makefile for the linux memory manager.## Note! Dependencies are done automagically by 'make dep', ...
- RobotFramwork + Appium+ Andriod 环境搭建
RF+Appium+Android环境搭建教程 - 1.RF安装 一.适用操作系统 Win7 旗舰版Sp1 32位操作系统 RF环境搭建,请参考文档<RobotFramwork安装指南> ...