Commit 2a786328 authored by Edwin Carlinet's avatar Edwin Carlinet
Browse files

Fix issue with filename in export function and set the number of

thread as a parameter of the program.

        *  apps/smartdoc/export.cpp: Fix filename issue.
        *  apps/smartdoc/main2.cpp: Add NTHREAD parameter.
parent 9d2fe866
......@@ -2,6 +2,7 @@
#include <iostream>
#include <fstream>
#include <chrono>
#include <string>
#include <boost/date_time/posix_time/posix_time.hpp>
void export_xml(const char* filename,
......@@ -14,10 +15,16 @@ void export_xml(const char* filename,
std::ofstream f(filename);
ptime now = second_clock::local_time();
std::string doc_id = document_id;
size_t pos = doc_id.rfind("test/");
if (pos != std::string::npos)
doc_id = doc_id.substr(pos + 5);
f << "<?xml version='1.0' encoding='utf-8'?>\n"
<< "<seg_result version=\"0.2\" generated=\"" << to_iso_string(now) << "\">\n"
<< "<seg_result version=\"0.2\" generated=\"" << to_iso_extended_string(now) << "\">\n"
<< " <software_used name=\"" << APP_NAME << "\" version=\"" << APP_VERSION << "\"/>\n"
<< " <source_sample_file>" << document_id << "</source_sample_file>\n"
<< " <source_sample_file>" << doc_id << "</source_sample_file>\n"
<< " <segmentation_results>\n"
;
......
......@@ -337,14 +337,15 @@ private:
int main(int argc, char** argv)
{
if (argc < 3) {
std::cerr << "Usage: " << argv[0] << " input.mpg output.xml [output.mpg]\n";
std::cerr << "Usage: " << argv[0] << " input.mpg output.xml [number of threads=10] [output.mpg]\n";
std::exit(1);
}
const char* input_path = argv[1];
const char* output_path = argv[2];
const char* output_video_path = (argc > 3) ? argv[3] : NULL;
VIDEO_OUTPUT = argc > 3;
int nthread = (argc > 3) ? std::atoi(argv[3]) : 10;
const char* output_video_path = (argc > 4) ? argv[4] : NULL;
VIDEO_OUTPUT = argc > 4;
using namespace mln;
......@@ -365,7 +366,7 @@ int main(int argc, char** argv)
tbb::filter_t<void,void> f = f1 & f2 & f3;
tbb::parallel_pipeline(4,f);
tbb::parallel_pipeline(nthread,f);
export_xml(output_path, input_path, &results[0], results.size());
}
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