filename specified by arg

This commit is contained in:
boyska 2017-01-05 18:22:17 +01:00
parent 24ce1a2339
commit 0d67802ba0

View file

@ -2,7 +2,19 @@
int main(int argc, char *argv[])
{
cv::Mat img=cv::imread("files/masckera.png",CV_LOAD_IMAGE_GRAYSCALE);
char const *fname = "files/masckera.png";
if( 1<argc )
fname = argv[1];
if( 2<argc) {
std::cerr << "Too many arguments" << std::endl;
return EXIT_FAILURE;
}
cv::Mat img;
img=cv::imread(fname,CV_LOAD_IMAGE_GRAYSCALE);
if( img.empty() ) {
std::cerr << "Error opening image, aborting" << std::endl;
return EXIT_FAILURE;
}
std::vector< std::vector<cv::Point> > contours;
std::vector<cv::Vec4i> hierarchy;