OpenCV open Euclidean distance between two vectors

I want to calculate the Euclidean distance between two vectors (or two Matrx strings, it doesn't matter). Is there a good feature for OpenCV?

+8
vector matrix opencv euclidean distance
source share
2 answers

Yes.

Mat a,b; // num of rows/cols/channels does not matter, they just have to be equal for both double dist = norm(a,b,NORM_L2); 
+20
source share

Source: OpenCV, C ++: distance between two points

 Mat pts1(nPts, 1, CV_8UC2), pts2(nPts, 1, CV_8UC2); // populate them Mat diffPts = pts1-pts2; Mat ptsx, ptsy; // split your points in x and y vectors. maybe separate them from start Mat dist; magnitude(ptsx, ptsy, dist); // voila! 
+2
source share

All Articles