Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between cv2.NORM_L2 and cv2.NORM_L1 in opencv python

I am using sift algorithm from python extra modules for some feature matching. Although one thing I did not understand is the concept behind the normType passed to the BFMatcher. i.e Which ones have to be used in what case?

Any help will be invaluable

like image 932
sp497 Avatar asked Sep 29 '15 16:09

sp497


People also ask

What is the difference between OpenCV and cv2?

cv2 (old interface in old OpenCV versions was named as cv ) is the name that OpenCV developers chose when they created the binding generators. This is kept as the import name to be consistent with different kind of tutorials around the internet.

Is OpenCV-Python and cv2 same?

cv2 is the module import name for opencv-python, "Unofficial pre-built CPU-only OpenCV packages for Python". The traditional OpenCV has many complicated steps involving building the module from scratch, which is unnecessary. I would recommend remaining with the opencv-python library.

What does cv2 ConvertScaleAbs do?

ConvertScaleAbs Method. Scales, computes absolute values and converts the result to 8-bit.

What is cv2 addWeighted?

The addWeighted function is a function that helps in adding two images and also blending those by passing the alpha, beta and gamma values. In order to analyse images, this helps in adjusting the gradients and in the processing of the image.


1 Answers

From WolframAlpha NormL1 and NormL2:

Given a vector:

enter image description here

Norm L1 is the taxicab (or manhattan) distance (sum of absolute values):

enter image description here

while Norm L2 is the euclidean distance (square root of sum of squares):

enter image description here

The type of norm tells the BFMatcher how to compute the distances between every two features.

The NORM L1 is in general much faster to compute (mostly because you don't compute the square root). The NORM L2 is more accurate.

You can find a nice comparison here.

like image 88
Miki Avatar answered Sep 19 '22 21:09

Miki