简体   繁体   English

在cpp中基于FFT的图像配准(可选择使用OpenCV)?

[英]FFT based image registration (optionally using OpenCV) in cpp?

I'm trying to align two images taken from a handheld camera. 我正在尝试对齐从手持相机拍摄的两张图像。

At first, I was trying to use the OpenCV warpPerspective method based on SIFT/SURF feature points. 起初,我试图使用基于SIFT / SURF特征点的OpenCV warpPerspective方法。 The problem is the feature-extract & matching process may be extremely slow when the image quality is high (3000x4000). 问题是当图像质量很高(3000x4000)时,特征提取和匹配过程可能会非常慢。 I tried to scale-down the image before find feature-points, the result is not as good as before.(The Mat generated from findHomography shouldn't be affected by scaling down the image, right?) And sometimes, due to lack of good feature point matches, the result is quite strange. 我试图在找到特征点之前缩小图像,结果不如以前那么好。(从findHomography生成的Mat不应该受到缩小图像的影响,对吧?)有时,由于缺乏好的特征点匹配,结果很奇怪。

After searching on this topic, it seems that solving the problem in Fourier domain will speed up the registration process. 在搜索了这个主题后,似乎解决Fourier域中的问题会加快注册过程。 And I've found this question which leads me to the code here . 我发现这个问题引导我到这里代码

The only problem is the code is written in python with numpy (not even using OpenCV), which makes it quite hard to re-written to C++ code using OpenCV (In OpenCV, I can only find dft and there's no fftshift nor fft stuff, I'm not quite familiar with NumPy, and I'm not brave enough to simply ignore the missing methods). 唯一的问题是代码是用python编写的numpy(甚至不使用OpenCV),这使得使用OpenCV重写C ++代码非常困难(在OpenCV中,我只能找到dft而且没有fftshiftfft东西,我对NumPy并不熟悉,而且我不够勇敢,只是忽略了丢失的方法)。 So I'm wondering why there is not such a Fourier-domain image registration implementation using C++? 所以我想知道为什么没有使用C ++进行这样的傅立叶域图像配准实现?

Can you guys give me some suggestion on how to implement one, or give me a link to the already implemented C++ version? 你们能给我一些关于如何实现一个的建议,或者给我一个已经实现的C ++版本的链接? Or help me to turn the python code into C++ code? 或者帮我把python代码转换成C ++代码?

Big thanks! 十分感谢!

I'm fairly certain that the FFT method can only recover a similarity transform, that is, only a (2d) rotation, translation and scale. 我相当确定FFT方法只能恢复相似变换,即只有(2d)旋转,平移和缩放。 Your results might not be that great using a handheld camera. 使用手持相机,您的结果可能不是那么好。

This is not quite a direct answer to your question, but, as a suggestion for a speed improvement, have you tried using a faster feature detector and descriptor? 这不是您问题的直接答案,但是,作为提高速度的建议,您是否尝试使用更快的特征检测器和描述符? In OpenCV SIFT/SURF are some of the slowest methods they have for feature extraction/matching. 在OpenCV中,SIFT / SURF是它们用于特征提取/匹配的最慢方法。 You could try testing some of their other methods first, they all work quite well and are faster than SIFT/SURF. 您可以先尝试测试其他一些方法,它们都能很好地工作并且比SIFT / SURF更快。 Especially if you use their FLANN -based matcher. 特别是如果你使用他们基于FLANN的匹配器。

I've had to do this in the past with similar sized imagery, and using the binary descriptors OpenCV has increases the speed significantly. 过去我必须使用类似大小的图像来执行此操作,并且使用二进制描述符OpenCV会显着提高速度。

如果您只需要转换,您可以使用OpenCV的相位相关

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM