TODO : @ARK : This function will have some changes when we support the latest SSD layerWidth, layerHeight : Width and Height of input feature map imageWidth, imageHeight : Width and Height of original input image aspect_ratios : Aspect ratios to be considered (float vector) min_size : minimum size to be specified (float vector) max_size : maximum size to be specified (float vector : optional ) fli
| 3322 | // step_h, step_w : in simple words, ratio of imageWidth/layerWidth (float : optional : default = -1.0) |
| 3323 | // offset : Used in priorbox calculation (float : optional : default = 0.0) |
| 3324 | vector<float> computePriorBoxes(int layerWidth, int layerHeight, int imageWidth, int imageHeight, |
| 3325 | const vector<float>& aspect_ratios_, const vector<float>& min_size, const vector<float>& max_size, const vector<float>& var, |
| 3326 | bool flip, bool clip, float step_h_, float step_w_, float offset_) |
| 3327 | { |
| 3328 | const int layer_width = layerWidth; |
| 3329 | const int layer_height = layerHeight; |
| 3330 | const int img_width = imageWidth; |
| 3331 | const int img_height = imageHeight; |
| 3332 | const float step_w = (step_w_ == 0) ? static_cast<float>(img_width) / layer_width : step_w_ ; |
| 3333 | const float step_h = (step_h_ == 0) ? static_cast<float>(img_height) / layer_height : step_h_ ; |
| 3334 | |
| 3335 | // Update aspect ratios with their reciprocals |
| 3336 | vector<float> aspect_ratios; |
| 3337 | aspect_ratios.push_back(1.); |
| 3338 | |
| 3339 | for (int i=0; i<aspect_ratios_.size(); i++) |
| 3340 | { |
| 3341 | float ar = aspect_ratios_[i]; |
| 3342 | bool processed = false; |
| 3343 | for(int j=0; j<aspect_ratios.size(); ++j) |
| 3344 | { |
| 3345 | // #. Check for duplicate values |
| 3346 | if(fabs(ar - aspect_ratios[j]) < 1e-6) |
| 3347 | { |
| 3348 | processed = true; |
| 3349 | break; |
| 3350 | } |
| 3351 | } |
| 3352 | if(!processed) |
| 3353 | { |
| 3354 | aspect_ratios.push_back(ar); |
| 3355 | if (flip) |
| 3356 | { |
| 3357 | aspect_ratios.push_back(1.0 / ar); |
| 3358 | } |
| 3359 | } |
| 3360 | } |
| 3361 | |
| 3362 | int num_priors = aspect_ratios.size() * min_size.size(); |
| 3363 | |
| 3364 | if(max_size.size() > 0) |
| 3365 | { |
| 3366 | for(int i=0; i<max_size.size(); ++i) |
| 3367 | { |
| 3368 | ASSERT( max_size[i] > min_size[i], EP100, |
| 3369 | "max_size shoule be larger than min_size for PriorBox Layer.") |
| 3370 | num_priors+=1; |
| 3371 | } |
| 3372 | } |
| 3373 | |
| 3374 | |
| 3375 | // Now we start creating the boxes |
| 3376 | |
| 3377 | int nboxes = layer_height * layer_width * num_priors; // Total number of boxes |
| 3378 | int dim = nboxes * 4; // Total size for boxes |
| 3379 | vector<float> priorboxes(2 * dim); // 2 * dim for [prior_box & variance] |
| 3380 | int idx = 0; |
| 3381 |
no test coverage detected