From 88e6ae4c36abe00c3e5bdc3b03c3dd2323c183b8 Mon Sep 17 00:00:00 2001 From: Ethan Rublee Date: Wed, 24 Nov 2010 16:39:13 +0000 Subject: [PATCH] adding a check for if the first arg is an image - annoying if it overwrites your files if you put in the wrong params. --- samples/cpp/imagelist_creator.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/samples/cpp/imagelist_creator.cpp b/samples/cpp/imagelist_creator.cpp index cc9b73a8f..f2d3bdaf2 100644 --- a/samples/cpp/imagelist_creator.cpp +++ b/samples/cpp/imagelist_creator.cpp @@ -2,6 +2,7 @@ */ #include "opencv2/core/core.hpp" +#include "opencv2/highgui/highgui.hpp" #include #include @@ -28,6 +29,13 @@ int main(int ac, char** av) 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); fs << "images" << "["; for(int i = 2; i < ac; i++){