Read an image with imread() [closed]
Hi people, I have this part of code and I d like to undrestand better it.
Mat img=imread("....."); //... is a path
if(argc>1)
img=imread(argv[1]);
if(img.empty(){
cerr <<" Error message:" << argv[1];
return 1;
}
if (img.empty(){
cout << "the image is empty\n";
return -1;
}
First line load an image by passing directly the path of the image. After it load an image if is passed by command line, as cmd, or terminal. Can I understand better how. Why is it used argv[1]? Is it a need to use 2 time the control about if the imafe is loaded? I understand is a control firstly for the second kind of loading image and after for the 1st (load by adding path)
First, what are you trying to accomplish, what is the goal you are trying to achieve?
Load an image by passing the path or by a command line interface (I don t know if the right term in English) . Howewer the code works.I just want to understand better why is used in that way. How is used about the command line loading in that way
I mean why argv[1] is the path of an image passed by command line?
This seems more like a C/C++ question than an OpenCV question. You need to figure out about
argv
.Yes, argv[1] is the first command line parameter.