Commit 88e6ae4c authored by Ethan Rublee's avatar Ethan Rublee

adding a check for if the first arg is an image - annoying if it overwrites

your files if you put in the wrong params.
parent 0a2881ad
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
*/ */
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <string> #include <string>
#include <iostream> #include <iostream>
...@@ -28,6 +29,13 @@ int main(int ac, char** av) ...@@ -28,6 +29,13 @@ int main(int ac, char** av)
string outputname = av[1]; string outputname = av[1];
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;
}
FileStorage fs(outputname, FileStorage::WRITE); FileStorage fs(outputname, FileStorage::WRITE);
fs << "images" << "["; fs << "images" << "[";
for(int i = 2; i < ac; i++){ for(int i = 2; i < ac; i++){
......
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