因此,我正在尝试使用SIFT将热像与rgb图像叠加,以匹配特征和单应性,以便以后可以叠加它们。我的代码适用于我大约50%的热/rgb集,但许多集,比如这个集,会产生可怕的结果。我认为单应性很好,但不起作用,因为匹配太远了。我会附上一些代码,任何关于如何调整这将是伟大的建议,因为我已经花了很长时间试图让这个工作在我自己。谢谢!
MIN_MATCH_COUNT = 10
sift = cv2.xfeatures2d.SIFT_create(sigma=1.6, contrastThreshold=0.04,edgeThreshold = 15)
kp1, des1 = sift.detectAndCompute(rgb, None)
kp2, des2 = sift.detectAndCompute(thermal, None)
bf = cv2.BFMatcher()
matches = bf.knnMatch(des1, des2, k=2)
good = []
for m, n in matches:
if m.distance < 0.8 * n.distance:
good.append(m)
good = sorted(good, key=lambda x: x.distance)
img3 = cv2.drawMatches(rgb, kp1, thermal, kp2, good, None, flags=2)它给出了以下内容

然后我用RANSAC对找到的匹配项做单应性分析
if len(good) > MIN_MATCH_COUNT:
src_pts = np.float32([kp1[m.queryIdx].pt for m in good]).reshape(-1, 1, 2)
dst_pts = np.float32([kp2[m.trainIdx].pt for m in good]).reshape(-1, 1, 2)
M, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC, 5.0, maxIters=1000)
matchesMask = mask.ravel().tolist()
h, w, c = rgb.shape
pts = np.float32([[0, 0], [0, h - 1], [w - 1, h - 1], [w - 1, 0]]).reshape(-1, 1, 2)
dst = cv2.perspectiveTransform(pts, M)
thermal = cv2.polylines(thermal, [np.int32(dst)], True, 255, 3, cv2.LINE_AA) # draw lines around as a box
draw_params = dict(matchColor=(0, 255, 0), # draw matches in green color
singlePointColor=None,
matchesMask=matchesMask, # draw only inliers
flags=2)
img3 = cv2.drawMatches(rgb, kp1, thermal, kp2, good, None, **draw_params)结果是这样的

正如我所说的,我认为这是失败的,因为BFMatcher没有找到正确的匹配,但我不确定原因。再次感谢大家的帮助!我试过使用球体探测器,将rgb图像转换为灰度,并将图像预取到类似的大小,但仍然得不到很好的结果。
这里是一个工作的rgb-热对的示例,以演示我正在尝试做的事情。

发布于 2018-06-20 08:27:52
你的图像的问题是,与自然图像相比,它太简单了(没有颜色,没有主要的纹理差异,等等),你不能可靠地使用SIFT和其他在脑海中使用普通照片的技术。大多数错误的匹配实际上都是好的匹配,因为这些匹配在本地看起来彼此相似(在获得描述符之后)。
我的建议是使用结构信息来寻找匹配图像的替代方案,或者向图像添加信息(例如,使用高度彩虹颜色映射,因为您的图像可以被视为凹凸贴图;使用距离变换+颜色映射可能也有效,或者使用上述两个+边缘检测作为非常奇怪但不同颜色图像的3个通道),并查看SIFT是否表现不同。
https://stackoverflow.com/questions/50937304
复制相似问题