我正在使用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
某人可以提出一些更有效的方法吗?
答案 0 :(得分:0)
将</tag>
设为queried_matches
。并使用set
而不是索引循环,因为不需要索引。
for m in matches: