1

I am new to this concept and I believe that is should be the silliest question anyone to ask here. SOrry but I am really not sure.

 image = imread(argv[1], CV_LOAD_IMAGE_COLOR);

My problem is, reading image using imread in opencv, i see in the samples that they use the function argv[1]. My confusion is that where is the image suppose to be stored so that i can read in this command method.

My image is stored in desktop in a folder image. My program is also on desktop with name. image.cpp.

Where should i place the image so i can used the command line to read it.

rish
  • 5,575
  • 6
  • 22
  • 27

3 Answers3

3

If you just want to test some OpenCV funciton, you can just define
char* file_path = "c:/.../image.jpg"; Then ,you can load this image

image = imread(file_path, CV_LOAD_IMAGE_COLOR);
flyzhao
  • 348
  • 4
  • 15
2

You can invoke it as:

program [file]

where program is the name of your program. On windows it will probably be program.exe. Whatever you put in [file] will be passed to your program in argv[1]. If they are both in the same directory you can do:

program file.jpg

If the file is in different directory than the program you will need to give the full path (or relative path from one to the other). You can experiment by writing a simple program that prints argv[1] just to make sure you understand how things work (avoid the OpenCV complexities at first).

carlosdc
  • 12,022
  • 4
  • 45
  • 62
1

Put the image anywhere. Just Pass the path of the file in the command line. As juanchopanza mentioned in comment, you should have read permission for the file.

Barshan Das
  • 3,677
  • 4
  • 32
  • 46