MCPcopy Create free account
hub / github.com/davisking/dlib / print_all_label_stats

Function print_all_label_stats

tools/imglab/src/main.cpp:192–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190// ----------------------------------------------------------------------------------------
191
192void print_all_label_stats (
193 const dlib::image_dataset_metadata::dataset& data
194)
195{
196 std::map<std::string, running_stats<double> > area_stats, aspect_ratio;
197 std::map<std::string, int> image_hits;
198 std::set<std::string> labels;
199 unsigned long num_unignored_boxes = 0;
200 for (unsigned long i = 0; i < data.images.size(); ++i)
201 {
202 std::set<std::string> temp;
203 for (unsigned long j = 0; j < data.images[i].boxes.size(); ++j)
204 {
205 labels.insert(data.images[i].boxes[j].label);
206 temp.insert(data.images[i].boxes[j].label);
207
208 area_stats[data.images[i].boxes[j].label].add(data.images[i].boxes[j].rect.area());
209 aspect_ratio[data.images[i].boxes[j].label].add(data.images[i].boxes[j].rect.width()/
210 (double)data.images[i].boxes[j].rect.height());
211
212 if (!data.images[i].boxes[j].ignore)
213 ++num_unignored_boxes;
214 }
215
216 // count the number of images for each label
217 for (std::set<std::string>::iterator i = temp.begin(); i != temp.end(); ++i)
218 image_hits[*i] += 1;
219 }
220
221 cout << "Number of images: "<< data.images.size() << endl;
222 cout << "Number of different labels: "<< labels.size() << endl;
223 cout << "Number of non-ignored boxes: " << num_unignored_boxes << endl << endl;
224
225 for (std::set<std::string>::iterator i = labels.begin(); i != labels.end(); ++i)
226 {
227 if (i->size() == 0)
228 cout << "Unlabeled Boxes:" << endl;
229 else
230 cout << "Label: "<< *i << endl;
231 cout << " number of images: " << image_hits[*i] << endl;
232 cout << " number of occurrences: " << area_stats[*i].current_n() << endl;
233 cout << " min box area: " << area_stats[*i].min() << endl;
234 cout << " max box area: " << area_stats[*i].max() << endl;
235 cout << " mean box area: " << area_stats[*i].mean() << endl;
236 cout << " stddev box area: " << area_stats[*i].stddev() << endl;
237 cout << " mean width/height ratio: " << aspect_ratio[*i].mean() << endl;
238 cout << " stddev width/height ratio: " << aspect_ratio[*i].stddev() << endl;
239 cout << endl;
240 }
241}
242
243// ----------------------------------------------------------------------------------------
244

Callers 1

mainFunction · 0.85

Calls 13

sizeMethod · 0.45
insertMethod · 0.45
addMethod · 0.45
areaMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
current_nMethod · 0.45
minMethod · 0.45
maxMethod · 0.45
meanMethod · 0.45

Tested by

no test coverage detected