| 370 | } |
| 371 | |
| 372 | static void NormalizeDesc( // take sqrt of elems and divide by L2 norm |
| 373 | VEC& desc) // io |
| 374 | { |
| 375 | double* const data = Buf(desc); |
| 376 | for (int i = 0; i < NSIZE(desc); i++) |
| 377 | data[i] = sqrt(data[i]); // sqrt reduces effect of outliers |
| 378 | const double norm = cv::norm(desc); // L2 norm |
| 379 | if (!IsZero(norm)) |
| 380 | { |
| 381 | const double scale = FINAL_SCALE / norm; |
| 382 | for (int i = 0; i < NSIZE(desc); i++) |
| 383 | data[i] *= scale; |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | // Hat::Init_ must be called before calling this function. |
| 388 | // |