利用汉明距离进行目标检测
Object Detection with Hamming distance
我使用FAST和FREAK来获得几个图像的描述符,然后我使用BruteForceMatcher匹配器应用knnMatch,接下来我使用循环来分离好的匹配:
float nndrRatio = 0.7f;
std::vector<KeyPoint> keypointsA, keypointsB;
Mat descriptorsA, descriptorsB;
std::vector< vector< DMatch > > matches;
int threshold=9;
// detect keypoints:
FAST(objectMat,keypointsA,threshold,true);
FAST(sceneMat,keypointsB,threshold,true);
FREAK extractor;
// extract descriptors:
extractor.compute( objectMat, keypointsA, descriptorsA );
extractor.compute( sceneMat, keypointsB, descriptorsB );
BruteForceMatcher<Hamming> matcher;
// match
matcher.knnMatch(descriptorsA, descriptorsB, matches, 2);
// good matches search:
vector< DMatch > good_matches;
for (size_t i = 0; i < matches.size(); ++i)
{
if (matches[i].size() < 2)
continue;
const DMatch &m1 = matches[i][0];
const DMatch &m2 = matches[i][1];
if(m1.distance <= nndrRatio * m2.distance)
good_matches.push_back(m1);
}
//If there are at least 7 good matches, then object has been found
if ( (good_matches.size() >=7))
{
cout << "OBJECT FOUND!" << endl;
}
我认为问题可能是好的匹配搜索方法,因为将其与FlannBasedMatcher一起使用效果很好,但与BruteForceMatcher一起使用则非常奇怪。我怀疑我可能在用这种方法胡说八道,因为汉明距离使用了二进制描述符,但我想不出适应它的方法!
任何链接、片段、想法,。。。请
你的代码不错,但我不认为这是你想要做的。你为什么选择这个方法?
如果你想使用OpenCV检测图像中的对象,你可能应该尝试级联分类。此链接将解释如何训练分类器。
编辑:如果您认为它太复杂,并且您想要检测的对象是平面的,您可以尝试本教程(它基本上是通过尝试找到对象和图像之间的单应性变换来计算inliers)。但是级联分类对于目标检测来说更为通用。
相关文章:
- 如何(从固定列表中)选择一个数字序列,该序列将与目标数字相加
- 使用CMake检测支持的C++标准
- 当套接字连接断开时检测C/C++Unix
- C++A*算法并不总是在路径中具有目标节点
- C/C++预处理器是否可以检测一些编译器选项
- WMI检测进程创建事件-c++
- 基于树莓pi的tensorflow lite量化ssd目标检测
- 为测试目标创建具有不同源文件夹的文件
- 下面是我为检测链接列表中的循环而制作的代码
- 落砂模拟碰撞检测C++和SFML
- 我可以检测和更改 gcc/g++ 中结构的当前数据对齐设置吗?
- 为什么C++编译器没有检测到正确声明的类?
- qmake:检测目标位宽(32 位或 64 位)
- Hausdorff距离目标检测
- 在Haxe中检测目标语言
- 使用SVM的目标检测
- 利用汉明距离进行目标检测
- 如何检测Qt Creator的目标(调试/发布)(Visual Studio)
- AddQtAndroidApk检测到错误的目标体系结构
- 目标检测:需要培训或不需要培训