NORM_HAMMIG2 and NORM_TYPE_MASK with same values (Bug #4208)
Description
I just found that in the enumeration used for the NORM TYPES, two types have the same value (HAMMING2 & TYPE_MASK):
enum { NORM_INF=1, NORM_L1=2, NORM_L2=4, NORM_L2SQR=5, NORM_HAMMING=6, NORM_HAMMING2=7, NORM_TYPE_MASK=7, NORM_RELATIVE=8, NORM_MINMAX=32 };
I'm not sure if this is a desired feature for some internal reason, but I was doing some unit tests in a personal project that depends on OpenCV and I discovered that. The same issue still present in the OpenCV 3.0 version.
History
Updated by Ilya Lavrenov about 10 years ago
Hi Luis,
Actually, it's not a bug. NORM_TYPE_MASK is necessary to separate type of norm from another additional flags, such as NORM_RELATIVE. So, the typical scenario is:
int normType = type & NORM_TYPE_MASK; bool isRelative = (type & NORM_RELATIVE) != 0;
So, NORM_TYPE_MASK must be greater or equal to maximum value of norm type (it's NORM_HAMMING2=7 in our case)
- Status changed from New to Cancelled
- Assignee changed from Vadim Pisarevsky to Ilya Lavrenov