2010-11-20 22:37:09 +01:00
|
|
|
/*this creates a yaml or xml list of files from the command line args
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "opencv2/core/core.hpp"
|
2010-11-24 17:39:13 +01:00
|
|
|
#include "opencv2/highgui/highgui.hpp"
|
2010-11-20 22:37:09 +01:00
|
|
|
#include <string>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
using std::cout;
|
|
|
|
using std::endl;
|
|
|
|
|
|
|
|
using namespace cv;
|
|
|
|
|
2012-06-07 19:21:29 +02:00
|
|
|
static void help(char** av)
|
2010-11-20 22:37:09 +01:00
|
|
|
{
|
2010-12-04 09:31:11 +01:00
|
|
|
cout << "\nThis creates a yaml or xml list of files from the command line args\n"
|
2012-06-07 19:21:29 +02:00
|
|
|
"usage:\n./" << av[0] << " imagelist.yaml *.png\n"
|
2010-11-20 22:37:09 +01:00
|
|
|
<< "Try using different extensions.(e.g. yaml yml xml xml.gz etc...)\n"
|
|
|
|
<< "This will serialize this list of images or whatever with opencv's FileStorage framework" << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int ac, char** av)
|
|
|
|
{
|
|
|
|
if (ac < 3)
|
|
|
|
{
|
|
|
|
help(av);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
string outputname = av[1];
|
|
|
|
|
2010-11-24 17:39:13 +01:00
|
|
|
Mat m = imread(outputname); //check if the output is an image - prevent overwrites!
|
|
|
|
if(!m.empty()){
|
|
|
|
std::cerr << "fail! Please specify an output file, don't want to overwrite you images!" << endl;
|
|
|
|
help(av);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-11-20 22:37:09 +01:00
|
|
|
FileStorage fs(outputname, FileStorage::WRITE);
|
|
|
|
fs << "images" << "[";
|
|
|
|
for(int i = 2; i < ac; i++){
|
|
|
|
fs << string(av[i]);
|
|
|
|
}
|
|
|
|
fs << "]";
|
|
|
|
return 0;
|
|
|
|
}
|