00001 /* This file is part of Polyora, a multi-target tracking library. 00002 Copyright (C) 2010 Julien Pilet 00003 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License along 00015 with this program. If not, see <http://www.gnu.org/licenses/>. 00016 00017 To contact the author of this program, please send an e-mail to: 00018 julien.pilet(at)calodox.org 00019 */ 00020 /* Julien Pilet, 2009. */ 00021 #ifndef PATCHTAGGER_H 00022 #define PATCHTAGGER_H 00023 00024 #include <cv.h> 00025 00026 class patch_tagger { 00027 public: 00028 00029 static const unsigned patch_size = 16; 00030 static const unsigned nb_zone = 4; 00031 static const unsigned nb_orient = 16; 00032 static const unsigned nb_test = 16; 00033 00034 static patch_tagger *singleton(); 00035 00036 struct descriptor { 00037 unsigned histo[nb_zone][nb_orient]; 00038 unsigned total; 00039 unsigned sum_orient[nb_orient]; 00040 float orientation; 00041 unsigned projection; 00042 float _rotated[patch_size][patch_size]; 00043 CvMat rotated; 00044 00045 void array(float *array); 00046 00047 descriptor(); 00048 descriptor(const descriptor &a); 00049 const descriptor &operator=(const descriptor &a); 00050 float correl(const descriptor &a); 00051 }; 00052 00053 void cmp_descriptor(CvMat *patch, descriptor *d, float subpix_u, float subpix_v); 00054 unsigned project(patch_tagger::descriptor *d); 00055 00056 00057 void precalc(); 00058 00059 protected: 00060 00061 struct histo_entry { 00062 unsigned weight1; 00063 unsigned weight2; 00064 unsigned char zone1; 00065 unsigned char zone2; 00066 }; 00067 00068 histo_entry weight_table[patch_size][patch_size]; 00069 00070 struct grad2polar_entry { 00071 unsigned length1; 00072 unsigned length2; 00073 unsigned char dir1; 00074 unsigned char dir2; 00075 }; 00076 grad2polar_entry cart2polar_table[512][512]; 00077 00078 00079 struct random_node { 00080 unsigned char zone1, orient1; 00081 unsigned char zone2, orient2; 00082 }; 00083 random_node random_tests[nb_test]; 00084 00085 static float _weight[patch_size][patch_size]; 00086 CvMat weight; 00087 static float tot_weight; 00088 00089 unsigned char _mask[patch_size][patch_size]; 00090 CvMat mask; 00091 static void compute_sift_descriptor(float* descr_pt, cv::Mat patch); 00092 }; 00093 00094 #endif