| 162 | } |
| 163 | |
| 164 | static VEC SubProf( // return the profile at given offset within fullprof |
| 165 | int offset, // in: offset along whisker in pixels |
| 166 | int proflen, // in |
| 167 | const VEC& fullprof) // in |
| 168 | { |
| 169 | CV_Assert(proflen > 1 && proflen < 100); // 100 is arb |
| 170 | CV_Assert(proflen % 2 == 1); // prof length must be odd |
| 171 | |
| 172 | VEC prof(1, proflen); // the profile at the given offset along whisker |
| 173 | |
| 174 | // copy the relevant part of fullprof into prof |
| 175 | |
| 176 | memcpy(Buf(prof), |
| 177 | Buf(fullprof) + offset + NSIZE(fullprof)/2 - NSIZE(prof)/2, |
| 178 | NSIZE(prof) * sizeof(prof(0))); |
| 179 | |
| 180 | // normalize prof |
| 181 | |
| 182 | double sum = SumAbsElems(prof); |
| 183 | if (!IsZero(sum)) |
| 184 | prof *= NSIZE(prof) / sum; |
| 185 | |
| 186 | return prof; |
| 187 | } |
| 188 | |
| 189 | VEC ClassicProf( // currently used only when training a new model |
| 190 | const Image& img, // in: the image scaled to this pyramid level |
no test coverage detected