def mark_outliers(error_list, trim_stddev): print("Marking outliers...") sum = 0.0 count = len(error_list) # numerically it is better to sum up a list of floatting point # numbers from smallest to biggest (error_list is sorted from # biggest to smallest) for line in reversed(error_list): sum += line[0] # stats on error values print(" computing stats...") mean = sum / count stddev_sum = 0.0 for line in error_list: error = line[0] stddev_sum += (mean - error) * (mean - error) stddev = math.sqrt(stddev_sum / count) print("mean = %.4f stddev = %.4f" % (mean, stddev)) # mark match items to delete print(" marking outliers...") mark_count = 0 for line in error_list: # print "line:", line if line[0] > mean + stddev * trim_stddev: cull.mark_feature(matches_orig, line[1], line[2], line[0]) cull.mark_feature(matches_opt, line[1], line[2], line[0]) mark_count += 1 return mark_count
def split_image_features(index, matches): # iterate through the match dictionary and mark any matches for # the specified image for deletion print("Marking feature matches for image:", index) count = 0 new_matches = [] for i, match in enumerate(matches): found_index = False found_group = False for j, p in enumerate(match[2:]): if p[0] == index: found_index = True elif proj.image_list[p[0]].name in groups[args.group]: found_group = True # split match if possible if found_index and found_group: count += 1 new_match = [list(match[0]), -1] for j, p in enumerate(match[2:]): if proj.image_list[p[0]].name in groups[args.group]: if p[0] != index: cull.mark_feature(matches, i, j, 0) # print('p:', p) new_match.append(p) if len(new_match) >= 4: # at least 2 images referenced new_matches.append(new_match) # add all the new match splits for m in new_matches: matches.append(m) return count, len(new_matches)