【发布时间】:2019-02-10 18:26:30
【问题描述】:
我正在使用 for 循环过滤来自 opencv knnFlann 匹配器的匹配项,但我需要对其进行优化
代码:
def orb_calc_matches(matches, distance_range=0.65):
good_matches = []
queried_matches = []
for i in range(len(matches)):
if len(matches[i]) == 2:
if ((matches[i][0].trainIdx not in queried_matches) and (matches[i][0].distance < distance_range * matches[i][1].distance)):
good_matches.append(matches[i][0])
queried_matches.append(matches[i][0].trainIdx)
return good_matches
有人可以提出一些更有效的方法吗?
【问题讨论】:
标签: python performance for-loop optimization