OpenCV euclidean distance between two vectors

只愿长相守 提交于 2019-12-03 13:23:08

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);
rafaoc

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!

Same for python :

    dist = cv2.norm(pts - dst, cv2.NORM_L2)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!