how to calculate euclidean distance in python opencv

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • varsha1901
    New Member
    • Mar 2014
    • 1

    how to calculate euclidean distance in python opencv

    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.

    Code:
    from collections import *
    from CBIR import *
    from experiment import *
    from scipy.spatial import distance
    
    result_list = list()
    i = 0
    a_list = list()
    b_list = list()
    a_list.append(feature_matrix_ip)
    while i < 9:
        b_list.append(feature_matrix_db[i])
        dist = distance.euclidean(a_list,b_list[i])
        result_list.append(dist)
        result_list_sort = OrderedDict(sorted(enumerate(result_list),key=lambda x: x[0])).keys()
        i = i + 1 
    res_lst_srt = zip(result_list,result_list_sort)
    res_lst_srt.sort()
    print res_lst_srt
    even if the image belongs to the database also, the distance will not be 0.0

    Any suggestions are welcome!
    Thanks for the support!
Working...