赞
踩
图像之间经过较大视差的匹配任务在于解决局部仿射不变特征的提取与描述,目前Harris/Hessian-Affine与MSER局部不变特征提取主要策略是采用拟合椭圆归一化方式。关于Harris-Affine与MSER-Affine算法都是首先提取尺度不变或区域中心(角、斑)点,然后归一化收敛到仿射变形6个参数估计,并不是完全的仿射估计方式,具体原理可以参考Harris-Affine仿射不变特征匹配算法与MSER仿射不变特征匹配算法。
Affine-SIFT算法不同于上述局部仿射算法,通过模拟相机镜头轴线与目标图像的所有成像夹角的方向参数:经度角与纬度角。通过经度角与纬度角来模拟图像所有视差下的仿射变形,然后使用SIFT算法来解决图像的尺度、平移旋转问题。简单概述一下Affine-SIFT算法的过程:
1 首先对待匹配两幅图像按照经度角、纬度角模式进行仿射变换插值重采样。
2 对变换后的图像进行SIFT算法特征匹配。
其实,可以直观看到Affine-SIFT算法只是一个框架:模拟视差变换后的图像匹配解决尺度、平移、旋转的特征匹配算法可以更换掉SIFT算法。例如:Affine-SURF、Affine-BRISK、Affine-ORB等算法为了对Affine-SIFT算法进行加速的功能。以此来满足仿射视差下的实时性要求问题。
辅助功能common.py文件:计时函数
# Python 2/3 compatibility from __future__ import print_function import sys PY3 = sys.version_info[0] == 3 if PY3: from functools import reduce import numpy as np import cv2 as cv # built-in modules import os import itertools as it from contextlib import contextmanager def clock(): return cv.getTickCount() / cv.getTickFrequency() @contextmanager def Timer(msg): print(msg, '...',) start = clock() try: yield finally: print("%.2f ms" % ((clock()-start)*1000))
辅助功能函数find_obj.py. 其中init_feature()为输入特征检测与描述子算法,分别有sift、surf、orb、akaze、brisk算法,然后进行匹配算法提纯特征点对!
# Python 2/3 compatibility from __future__ import print_function import numpy as np import cv2 as cv #from common import anorm, getsize FLANN_INDEX_KDTREE = 1 # bug: flann enums are missing FLANN_INDEX_LSH = 6 def init_feature(name): chunks = name.split('-') if chunks[0] == 'sift': detector = cv.xfeatures2d.SIFT_create() norm = cv.NORM_L2 elif chunks[0] == 'surf': detector = cv.xfeatures2d.SURF_create(800) norm = cv.NORM_L2 elif chunks[0] == 'orb': detector = cv.ORB_create(400) norm = cv.NORM_HAMMING elif chunks[0] == 'akaze': detector = cv.AKAZE_create() norm = cv.NORM_HAMMING elif chunks[0] == 'brisk': detector = cv.BRISK_create() norm = cv.NORM_HAMMING else: return None, None if 'flann' in chunks: if norm == cv.NORM_L2: flann_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5) else: flann_params= dict(algorithm = FLANN_INDEX_LSH, table_number = 6, # 12 key_size = 12, # 20 multi_probe_level = 1) #2 matcher = cv.FlannBasedMatcher(flann_params, { }) # bug : need to pass empty dict (#1329) else: matcher = cv.BFMatcher(norm) return detector, matcher def filter_matches(kp1, kp2, matches, ratio = 0.75): mkp1, mkp2 = [], [] for m in matches:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。