def calc_error_for_nearest_neighbors_2d(accurate_values, current_values, settings_obj): error = [] #---turn the lists into dictionaries mydict_of_acc = dictionarize(accurate_values) mydict_of_cur = dictionarize(current_values); for key in mydict_of_cur.keys(): #go through each key and cal error if key in mydict_of_acc.keys(): #make sure ref1 is the small list if len(mydict_of_acc[key]) > len(mydict_of_cur[key]): ref1 = mydict_of_acc ref2 = mydict_of_cur else: ref2 = mydict_of_acc ref1 = mydict_of_cur #get the list of indecies of nearest neighbors indecies = nearest_neighbors_2d(ref2[key][:], ref1[key][:]) #calculate error for i in range(len(indecies)): error.append(tuple(numpy.subtract(ref2[key][i], ref1[key][indecies[i]]))) #error.append(find_dis(ref2[key][i], ref1[key][indecies[i]])) if (len(error) == 0 and not(settings_obj.benchmark_name == "sift")): print "assert(len(error)>0) unless benchmark =sift" exit(0) """ if (settings.benchmark_name == "sift"): if len(error) == 0: #the reason for it to be None is b/c in sift there is a #possibility that the octaves (with sift points) don't overlap error = float("inf") """ return error
def calc_error_for_nearest_neighbors(x_temp,y_temp): assert(len(x_temp) >0) assert(len(y_temp) >0) if (len(x_temp) > len(y_temp)): x_temp_temp = x_temp x_temp = y_temp y_temp = x_temp_temp x = x_temp y = y_temp error = [] nearst_neighbors = nearest_neighbors_sorted(x,y) print "here is x" print x print "here is y" print y for i in range(min(len(x), len(y))): error.append(abs(x[i] - y[nearst_neighbors[i]])) return error