By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,985 Members | 2,884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,985 IT Pros & Developers. It's quick & easy.

how to calculate euclidean distance in python opencv

P: 1
hey guys, i am trying to calculate the euclidean distance, but it is not giving me the proper values. i have no idea, whether the problem is with my code or the IDE i'm using. I use enthought canopy with python and opencv.

Expand|Select|Wrap|Line Numbers
  1. from collections import *
  2. from CBIR import *
  3. from experiment import *
  4. from scipy.spatial import distance
  5.  
  6. result_list = list()
  7. i = 0
  8. a_list = list()
  9. b_list = list()
  10. a_list.append(feature_matrix_ip)
  11. while i < 9:
  12.     b_list.append(feature_matrix_db[i])
  13.     dist = distance.euclidean(a_list,b_list[i])
  14.     result_list.append(dist)
  15.     result_list_sort = OrderedDict(sorted(enumerate(result_list),key=lambda x: x[0])).keys()
  16.     i = i + 1 
  17. res_lst_srt = zip(result_list,result_list_sort)
  18. res_lst_srt.sort()
  19. print res_lst_srt
  20.  
even if the image belongs to the database also, the distance will not be 0.0

Any suggestions are welcome!
Thanks for the support!
Mar 13 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.