Loading images in Argument
Hi, i have to load 4 images that i uploaded in the Argument section(run-run properties- arguments) and i am trying to load them with "argv[i]". I always have the same input: Usage: display_image ImageToLoadAndDisplay
Can you please tell me where is the error? i think it may be in the Arguments field, maybe there is some special character to divide arguments, by now i am just writing the location of the image with one space within every location. This is my code.
int main( int argc, char** argv )
{
if( argc != 2)
{
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}
Mat images[4];
Mat spectrum[4];
for (int i=1;i<5;i++)
{
images[i-1]=imread(argv[i], CV_LOAD_IMAGE_GRAYSCALE );
if(! images[i-1].data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
Fourier(images[i-1],spectrum[i-1]);
string name="image number "+ i;
string nameSpectrum= "spectrum number " + i;
namedWindow(name, CV_WINDOW_AUTOSIZE );
imshow(name, images[i] );
namedWindow(nameSpectrum, CV_WINDOW_AUTOSIZE );
imshow(nameSpectrum, spectrum[i] );
waitKey(0);
}
if you want 4 images, change
if( argc != 2)
toif( argc != 5)
// 4 images + progname