def compare_distances(self, train_img, cluster):
# sometimes the sift algorithm matches random points on screen so therefore
# it is necessary to determine the euclidean distances between these points
distances = euclidean_distances([self.kmeans.cluster_centers_[0]], cluster)
height, width = train_img.shape
new_cluster = []
# If all the points are greater than np.sqrt((width / 2) ** 2 + (height / 2) ** 2)
# Which then we can assume that they are not correct
# this will only work on images that fit the same dimensions against the query image
for index, distance in enumerate(distances[0]):
if distance <= np.sqrt((width / 2) ** 2 + (height / 2) ** 2):
new_cluster.append(cluster[index])
return new_cluster
评论列表
文章目录