473,473 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to calculate euclidean distance in python opencv

1 New Member
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
0 1673

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

Similar topics

17
by: Tim Daneliuk | last post by:
Is anyone aware of freely available Python modules that can do any of the following tasks: 1) Given the latitude/longitude of two locations, compute the distance between them. "Distance" in...
0
by: Claudio Grondi | last post by:
What is the current status of Python OpenCV interface i.e. the opencv module? \OpenCV\samples\python\contours.py gives following ERROR: OpenCV Python version of contours Traceback (most recent...
0
by: Peter Otten | last post by:
QOTW: "If you can find a workable solution not involving metaclasses and decorators, don't use them" - Michele Simionato "Newest Beautiful Soup beta solves everyone's problems that I know of." -...
10
by: Alan Johnson | last post by:
24.1.1.3 says about InputIterators: Algorithms on input iterators should never attempt to pass through the same iterator twice. They should be single pass algorithms. In 24.3.4.4 summarizes the...
0
by: Ronald S. Cook | last post by:
I'm looking for code to calculate the distancde (in miles) between two cities. I'm assuming latitude/longitude would be the inputs (which I'll derive from zip codes being entered by the user). ...
1
parshupooja
by: parshupooja | last post by:
Hi All I have a gridview where I have to show 3 columns: first location address, second Location address and third is distance between first location and second location. I don't know how to...
4
by: cmrhema | last post by:
Hello I am having a table where the speed of the vehicle at the respective time are stored. Now I should calculate distance the eg details of vehicle No(VNo), speed,datetime is given below vno ...
11
by: devnew | last post by:
hello while trying to write a function that processes some numpy arrays and calculate euclidean distance ,i ended up with this code (though i used numpy ,i believe my problem has more to do with...
7
by: nisha chaudhary | last post by:
i am working on project of online courier service and i have to calculate distance between 2 cities .how i can calculate distance between 2 cities using jsp code?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.