38 int readDataFile( vector<C_DataFromFilePtr>& data_gts ,
int values_per_scan)
41 string path = ros::package::getPath(
"roslib");
42 ifstream source(
"src/gt_datas/GT_NEW_DIV.txt");
44 if (!source.is_open())
46 cout <<
"Couldn't open the GT_NEW file" << endl;
54 getline(source, line);
62 sscanf(line.c_str(),
"%*c %d",&it);
66 data_gt->iteration = it;
68 getline(source ,line);
74 const char*ptr = line.c_str();
76 while(c < values_per_scan)
78 sscanf(ptr,
"%lf", &x);
80 data_gt->x_valuesf.push_back(x);
84 ptr = strstr(ptr,
" ");
99 getline(source , line);
100 const char*ptr2 = line.c_str();
103 while(c < values_per_scan)
105 sscanf(ptr2,
"%lf" , &y);
107 data_gt->y_valuesf.push_back(y);
110 ptr2 = strstr(ptr2,
" ");
125 getline(source , line);
126 const char*ptr3 = line.c_str();
129 while(c < values_per_scan)
131 sscanf(ptr3,
"%d" , &label);
133 data_gt->labels.push_back(label);
136 ptr3 = strstr(ptr3,
" ");
151 data_gts.push_back(data_gt);
155 cout<<
"close file"<<endl;
165 return p1->cluster_id < p2->cluster_id;
174 if( points[0]->label != 0 )
179 p->label = points[0]->label;
180 p->cluster_id = points[0]->cluster_id;
182 cluster_gt->support_points.push_back(p);
185 cluster_gt->id = p->cluster_id;
190 for(uint idx = 1; idx < points.size(); idx++ )
192 if(points[idx]->cluster_id== 0)
195 if( (points[idx]->cluster_id != points[idx-1]->cluster_id))
198 if(cluster_gt->support_points.size()>0)
199 clusters_GT.push_back(cluster_gt);
205 p->x = points[idx]->x;
206 p->y = points[idx]->y;
207 p->label = points[idx]->label;
208 p->cluster_id = points[idx]->cluster_id;
210 cluster_gt->support_points.push_back(p);
213 cluster_gt->id = p->cluster_id;
218 p->x = points[idx]->x;
219 p->y = points[idx]->y;
220 p->label = points[idx]->label;
221 p->cluster_id = points[idx]->cluster_id;
223 cluster_gt->support_points.push_back(p);
227 cluster_gt->id = p->cluster_id;
232 if(cluster_gt->support_points.size()>0)
233 clusters_GT.push_back(cluster_gt);
235 cout<<
"Clusters GT " << clusters_GT.size() << endl;
237 return clusters_GT.size();
PointPtr calculateClusterCentroid(vector< PointPtr > support_points)
Calculates the cluster's centroid.
int convertPointsToCluster(vector< PointPtr > &points, vector< ClusterPtr > &clusters_GT)
Performs Segmentation operation with the Adaptative Breakpoint Detector.
bool comparePoints(PointPtr p1, PointPtr p2)
Comparison function.
boost::shared_ptr< Point > PointPtr
Clustering related functions header.
PointPtr calculateClusterMedian(vector< PointPtr > support_points)
Calculates the cluster's central point.
boost::shared_ptr< Cluster > ClusterPtr
int readDataFile(vector< C_DataFromFilePtr > &data_gts, int values_per_scan)
Reads from a file the x, y and labels values from all the laser points from one iteration.
boost::shared_ptr< C_DataFromFile > C_DataFromFilePtr
Groundtruth related functions header.