总体理解

范数可以理解成距离
范数的存在是为了解决向量之间的距离问题

image.png

比如人脸识别中获得了两个人脸的特征向量之后
为了获取两个特征向量之间的距离,可以求特征向量之差的L2范数,就是两个特征向量之间的距离了。

python numpy求范数

linalg=linear(线性)+algebra(代数),norm则表示范数。
np.linalg.norm

x_norm=np.linalg.norm(x, ord=None, axis=None, keepdims=False)

opencv中求范数

norm_type = 4; //L2范数
cv::Mat feature1= cv::Mat(vector_feature, true).reshape(1, 1);
cv::Mat feature2= cv::Mat(vector_feature, true).reshape(1, 1);
dist_temp = norm(feature1 - feature2, norm_type);