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

Function convert_pascal_xml

tools/imglab/src/convert_pascal_xml.cpp:200–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198}
199
200void convert_pascal_xml(
201 const command_line_parser& parser
202)
203{
204 cout << "Convert from PASCAL XML annotation format..." << endl;
205
206 dlib::image_dataset_metadata::dataset dataset;
207
208 std::string name;
209 dlib::image_dataset_metadata::image img;
210
211 const std::string filename = parser.option("c").argument();
212 // make sure the file exists so we can use the get_parent_directory() command to
213 // figure out it's parent directory.
214 make_empty_file(filename);
215 const std::string parent_dir = get_parent_directory(file(filename)).full_name();
216
217 for (unsigned long i = 0; i < parser.number_of_arguments(); ++i)
218 {
219 try
220 {
221 parse_annotation_file(parser[i], img, name);
222 const string root = get_parent_directory(get_parent_directory(file(parser[i]))).full_name();
223 const string img_path = root + directory::get_separator() + "JPEGImages" + directory::get_separator();
224
225 dataset.name = name;
226 img.filename = strip_path(img_path + img.filename, parent_dir);
227 dataset.images.push_back(img);
228
229 }
230 catch (exception& )
231 {
232 cout << "Error while processing file " << parser[i] << endl << endl;
233 throw;
234 }
235 }
236
237 save_image_dataset_metadata(dataset, filename);
238}
239

Callers 1

mainFunction · 0.85

Calls 8

make_empty_fileFunction · 0.85
get_parent_directoryFunction · 0.85
strip_pathFunction · 0.85
number_of_argumentsMethod · 0.80
parse_annotation_fileFunction · 0.70
fileClass · 0.50
push_backMethod · 0.45

Tested by

no test coverage detected