Diff of /trunk/contrib/brl/bseg/boxm2/volm/boxm2_volm_matcher_p0.cxx [r36939] .. [r36940] Maximize Restore

  Switch to side-by-side view

--- a/trunk/contrib/brl/bseg/boxm2/volm/boxm2_volm_matcher_p0.cxx
+++ b/trunk/contrib/brl/bseg/boxm2/volm/boxm2_volm_matcher_p0.cxx
@@ -7,16 +7,18 @@
 
 struct scorecomp
 {
-    bool operator()( vcl_pair<float,int> & a, vcl_pair<float,int> & b) const
+    bool operator()( vcl_pair<float,int> const& a, vcl_pair<float,int> const& b) const
     {
         return a.first >b.first;
     }
 } scorecomp_obj;
+
 boxm2_volm_matcher_p0::~boxm2_volm_matcher_p0()
 {
 }
 
-boxm2_volm_matcher_p0::boxm2_volm_matcher_p0(volm_camera_space_sptr cam_space,volm_spherical_region_query srq,float threshold):cam_space_(cam_space),query_(srq),threshold_(threshold),count_(0)
+boxm2_volm_matcher_p0::boxm2_volm_matcher_p0(volm_camera_space_sptr cam_space,volm_spherical_region_query srq,float threshold)
+: count_(0),cam_space_(cam_space),query_(srq),threshold_(threshold)
 {
     unsigned int count = 0;
     for ( camera_space_iterator iter = cam_space_->begin(); iter != cam_space_->end(); ++iter,++count)
@@ -28,12 +30,11 @@
         unsigned head_index;
         unsigned tilt_index;
         iter->cam_indices(roll_index,fov_index,head_index,tilt_index);
-        double score = 0.0;
         volm_spherical_regions_layer q_regions =query_.query_regions(roll_index);
 
         vcl_vector<vsph_sph_box_2d> xfomred_boxes;
         vsph_sph_box_2d imbox;
-        for (unsigned i = 0; i< q_regions.size(); ++i)
+        for (int i = 0; i< q_regions.size(); ++i)
         {
             imbox.add(q_regions.regions()[i].bbox_ref().min_point());
             imbox.add(q_regions.regions()[i].bbox_ref().max_point());
@@ -45,11 +46,10 @@
                                                         (camera.top_fov_)/cam_space_->top_fov(0),
                                                         180-camera.tilt_,90-camera.heading_,false);
         imbox_xformed_[count] = imbox_xfomred;
-        for (unsigned i = 0; i< q_regions.size(); ++i)
+        for (int i = 0; i< q_regions.size(); ++i)
         {
             // transform query_region box
             volm_spherical_region query_region = q_regions.regions()[i];
-            unsigned char qval = 0;
             vsph_sph_box_2d qbox = query_region.bbox_ref();
             //: convert google coordinate axis( z is down and x is north) to spherical coordinate system (z is up and x is east)
             vsph_sph_box_2d qbox_xfomred = qbox.transform(camera.tilt_-cam_space_->tilt_mid(),
@@ -69,9 +69,9 @@
 {
     vul_timer t;
     t.mark();
-    spherical_region_attributes attributes_to_match[] = {spherical_region_attributes::ORIENTATION,
-                                                         spherical_region_attributes::NLCD,
-                                                         spherical_region_attributes::SKY};
+    spherical_region_attributes attributes_to_match[] = {ORIENTATION,
+                                                         NLCD,
+                                                         SKY};
     vcl_vector<vcl_pair<float,int> > scores;
     volm_spherical_regions_layer index_layer = index.index_regions();
     vcl_vector<volm_spherical_region> i_regions = index_layer.regions();
@@ -89,7 +89,7 @@
         vcl_map<unsigned char, double> scores_by_lcd;
         //this->match_order(index_layer,score,q_regions,iter,imbox_xformed_[count]);
         vcl_map<unsigned char, int> score_nlcd ;
-        for (unsigned i = 0; i< q_regions.size(); ++i)
+        for (int i = 0; i< q_regions.size(); ++i)
         {
             volm_spherical_region query_region = q_regions.regions()[i];
             unsigned char qval = 0;
@@ -105,9 +105,9 @@
                     volm_spherical_region index_region = i_regions[attribute_poly_ids[j]];
                     //: just considering horizontal and vertical
                     double int_area = intersection_area(qbox_xfomred,index_region.bbox_ref())/(qbox_xfomred.area());
-                    if (attributes_to_match[k] == spherical_region_attributes::ORIENTATION)
+                    if (attributes_to_match[k] == ORIENTATION)
                         score+= 0.01 * int_area;
-                    else if (attributes_to_match[k] == spherical_region_attributes::SKY)
+                    else if (attributes_to_match[k] == SKY)
                         score+= 1.0 * int_area;
                     else
                     {
@@ -117,14 +117,14 @@
                 }
             }
         }
-        for (vcl_map<unsigned char, int>::iterator iter = score_nlcd.begin(); iter!=score_nlcd.end(); ++iter)
-            score+=(float)iter->second;
+        for (vcl_map<unsigned char, int>::iterator map_iter = score_nlcd.begin(); map_iter!=score_nlcd.end(); ++map_iter)
+            score+=(float)map_iter->second;
         scores.push_back(vcl_make_pair<float,int>((float)score,(*iter).cam_index()));
     }
     //vcl_cout<<"Time taken is "<< t.all()<<vcl_endl;
     float max_score = -1e10;
     int max_cam_id = -1;
-   int grndtruthindex = cam_space_->closest_index(cam_angles(cam_space_->roll_mid(),cam_space_->top_fovs()[0],cam_space_->head_mid(),cam_space_->tilt_mid()));
+    int grndtruthindex = cam_space_->closest_index(cam_angles(cam_space_->roll_mid(),cam_space_->top_fovs()[0],cam_space_->head_mid(),cam_space_->tilt_mid()));
     vcl_cout<<"INDEX of Ground Truth cam "<<grndtruthindex<<" and the score is "<< scores[grndtruthindex].first<<vcl_endl;
     //: selecting the top 200 cameras and the best camera location
     vcl_sort(scores.begin(),scores.end(),scorecomp_obj);
@@ -157,7 +157,7 @@
     //: compute mean or min depth for each query box
     cam_angles camera = iter->camera_angles();
     vcl_vector<volm_spherical_region> i_regions = index_layer.regions();
-    vcl_vector<unsigned int> attribute_poly_ids = index_layer.attributed_regions_by_type_only(spherical_region_attributes::DEPTH_INTERVAL);
+    vcl_vector<unsigned int> attribute_poly_ids = index_layer.attributed_regions_by_type_only(DEPTH_INTERVAL);
 
     vcl_vector<float> depths ;
     vcl_vector<unsigned char> depth_intervals ;
@@ -168,14 +168,14 @@
         if (intersection_area(imbox_xfomred,index_region.bbox_ref()) > 0.0)
             reduced_attribute_poly_ids.push_back(attribute_poly_ids[j]);
     }
-    for (unsigned i = 0; i< q_regions.size(); ++i)
+    for (int i = 0; i< q_regions.size(); ++i)
     {
         // transform query_region box
         volm_spherical_region query_region = q_regions.regions()[i];
         unsigned char qval ;
-        q_regions.regions()[i].attribute_value(spherical_region_attributes::DEPTH_ORDER, qval);
-        if ( qval == 255 || q_regions.regions()[i].is_attribute(spherical_region_attributes::SKY) ||
-             q_regions.regions()[i].is_attribute(spherical_region_attributes::GROUND) )
+        q_regions.regions()[i].attribute_value(DEPTH_ORDER, qval);
+        if ( qval == 255 || q_regions.regions()[i].is_attribute(SKY) ||
+             q_regions.regions()[i].is_attribute(GROUND) )
             continue;
         depth_intervals.push_back(qval);
         vsph_sph_box_2d qbox_xfomred = query_xformed_boxes_[iter->cam_index()][i];
@@ -186,8 +186,8 @@
         {
             volm_spherical_region index_region = i_regions[reduced_attribute_poly_ids[j]];
             float area = intersection_area(qbox_xfomred,index_region.bbox_ref());
-            unsigned char ival = 0.0;
-            index_region.attribute_value(spherical_region_attributes::DEPTH_INTERVAL,ival);
+            unsigned char ival = (unsigned char)0;
+            index_region.attribute_value(DEPTH_INTERVAL,ival);
             mean_depth+=area*vcl_pow(1.01f,(float)ival);
             sum_weights+=area;
         }
@@ -201,5 +201,5 @@
                  (depth_intervals[i] > depth_intervals[j] || depths[i] < depths[j] ) )
                 score+=0.1;
 
-   return true;
-}
+    return true;
+}