Commit 0175116f authored by Davis King's avatar Davis King

renamed some things

parent fbce4cd6
...@@ -20,7 +20,7 @@ using namespace dlib; ...@@ -20,7 +20,7 @@ using namespace dlib;
namespace dlib namespace dlib
{ {
namespace imglab namespace image_dataset_metadata
{ {
struct box struct box
{ {
...@@ -45,7 +45,7 @@ namespace dlib ...@@ -45,7 +45,7 @@ namespace dlib
std::vector<box> boxes; std::vector<box> boxes;
}; };
struct image_dataset_metadata struct dataset
{ {
std::vector<image> images; std::vector<image> images;
std::string comment; std::string comment;
...@@ -68,13 +68,13 @@ namespace dlib ...@@ -68,13 +68,13 @@ namespace dlib
} }
void save_image_dataset_metadata ( void save_image_dataset_metadata (
const image_dataset_metadata& metadata, const dataset& meta,
const std::string& filename const std::string& filename
) )
{ {
create_image_metadata_stylesheet_file(); create_image_metadata_stylesheet_file();
const std::vector<image>& images = metadata.images; const std::vector<image>& images = meta.images;
ofstream fout(filename.c_str()); ofstream fout(filename.c_str());
if (!fout) if (!fout)
...@@ -83,8 +83,8 @@ namespace dlib ...@@ -83,8 +83,8 @@ namespace dlib
fout << "<?xml version='1.0' encoding='ISO-8859-1'?>\n"; fout << "<?xml version='1.0' encoding='ISO-8859-1'?>\n";
fout << "<?xml-stylesheet type='text/xsl' href='image_metadata_stylesheet.xsl'?>\n"; fout << "<?xml-stylesheet type='text/xsl' href='image_metadata_stylesheet.xsl'?>\n";
fout << "<dataset>\n"; fout << "<dataset>\n";
fout << "<name>" << metadata.name << "</name>\n"; fout << "<name>" << meta.name << "</name>\n";
fout << "<comment>" << metadata.comment << "</comment>\n"; fout << "<comment>" << meta.comment << "</comment>\n";
fout << "<images>\n"; fout << "<images>\n";
for (unsigned long i = 0; i < images.size(); ++i) for (unsigned long i = 0; i < images.size(); ++i)
{ {
...@@ -137,21 +137,21 @@ namespace dlib ...@@ -137,21 +137,21 @@ namespace dlib
image temp_image; image temp_image;
box temp_box; box temp_box;
image_dataset_metadata& metadata; dataset& meta;
public: public:
doc_handler( doc_handler(
image_dataset_metadata& metadata_ dataset& metadata_
): ):
metadata(metadata_) meta(metadata_)
{} {}
virtual void start_document ( virtual void start_document (
) )
{ {
metadata = image_dataset_metadata(); meta = dataset();
ts.clear(); ts.clear();
temp_image = image(); temp_image = image();
temp_box = box(); temp_box = box();
...@@ -236,7 +236,7 @@ namespace dlib ...@@ -236,7 +236,7 @@ namespace dlib
} }
else if (name == "image" && ts.back() == "images") else if (name == "image" && ts.back() == "images")
{ {
metadata.images.push_back(temp_image); meta.images.push_back(temp_image);
temp_image = image(); temp_image = image();
} }
} }
...@@ -247,11 +247,11 @@ namespace dlib ...@@ -247,11 +247,11 @@ namespace dlib
{ {
if (ts.size() == 2 && ts[1] == "name") if (ts.size() == 2 && ts[1] == "name")
{ {
metadata.name = trim(data); meta.name = trim(data);
} }
else if (ts.size() == 2 && ts[1] == "comment") else if (ts.size() == 2 && ts[1] == "comment")
{ {
metadata.comment = trim(data); meta.comment = trim(data);
} }
else if (ts.size() >= 2 && ts[ts.size()-1] == "label" && else if (ts.size() >= 2 && ts[ts.size()-1] == "label" &&
ts[ts.size()-2] == "box") ts[ts.size()-2] == "box")
...@@ -294,12 +294,12 @@ namespace dlib ...@@ -294,12 +294,12 @@ namespace dlib
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
void load_image_dataset_metadata ( void load_image_dataset_metadata (
image_dataset_metadata& metadata, dataset& meta,
const std::string& filename const std::string& filename
) )
{ {
xml_error_handler eh; xml_error_handler eh;
doc_handler dh(metadata); doc_handler dh(meta);
std::ifstream fin(filename.c_str()); std::ifstream fin(filename.c_str());
if (!fin) if (!fin)
...@@ -427,7 +427,7 @@ int main(int argc, char** argv) ...@@ -427,7 +427,7 @@ int main(int argc, char** argv)
if (parser.option("c")) if (parser.option("c"))
{ {
using namespace dlib::imglab; using namespace dlib::image_dataset_metadata;
const std::string filename = parser.option("c").argument(); const std::string filename = parser.option("c").argument();
// make sure the file exists so we can use the get_parent_directory() command to // make sure the file exists so we can use the get_parent_directory() command to
...@@ -439,15 +439,15 @@ int main(int argc, char** argv) ...@@ -439,15 +439,15 @@ int main(int argc, char** argv)
if (parser.option("r")) if (parser.option("r"))
depth = 30; depth = 30;
image_dataset_metadata metadata; dataset meta;
metadata.name = "imglab dataset"; meta.name = "imglab dataset";
metadata.comment = "Created by imglab tool."; meta.comment = "Created by imglab tool.";
for (unsigned long i = 0; i < parser.number_of_arguments(); ++i) for (unsigned long i = 0; i < parser.number_of_arguments(); ++i)
{ {
try try
{ {
const string temp = strip_path(file(parser[i]).full_name(), parent_dir); const string temp = strip_path(file(parser[i]).full_name(), parent_dir);
metadata.images.push_back(image(temp)); meta.images.push_back(image(temp));
} }
catch (dlib::file::file_not_found&) catch (dlib::file::file_not_found&)
{ {
...@@ -460,21 +460,21 @@ int main(int argc, char** argv) ...@@ -460,21 +460,21 @@ int main(int argc, char** argv)
for (unsigned long j = 0; j < files.size(); ++j) for (unsigned long j = 0; j < files.size(); ++j)
{ {
metadata.images.push_back(image(strip_path(files[j].full_name(), parent_dir))); meta.images.push_back(image(strip_path(files[j].full_name(), parent_dir)));
} }
} }
} }
save_image_dataset_metadata(metadata, filename); save_image_dataset_metadata(meta, filename);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
if (parser.number_of_arguments() == 1) if (parser.number_of_arguments() == 1)
{ {
dlib::imglab::image_dataset_metadata metadata; dlib::image_dataset_metadata::dataset meta;
load_image_dataset_metadata(metadata, parser[0]); load_image_dataset_metadata(meta, parser[0]);
save_image_dataset_metadata(metadata, "out.xml"); save_image_dataset_metadata(meta, "out.xml");
} }
} }
catch (exception& e) catch (exception& e)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment