我想计算两个向量(或两个矩阵行,无所谓)之间的欧几里得距离。在OpenCV中有没有一个好的函数可以做到这一点?
我想计算两个向量(或两个矩阵行,无所谓)之间的欧几里得距离。在OpenCV中有没有一个好的函数可以做到这一点?
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);
同样适用于Python:
dist = cv2.norm(pts - dst, cv2.NORM_L2)
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!
diffPts
变量? - Scott