i have a problem of which i am not sure where it comes from. Please take a look at this function:
http://pastie.org/8200205
imread appears to return empty matrices.
To be clear, my images are in the directory ImageData which is directly where my program lies, and for each object type like apple, i have a directory that is called like the object type and inside are all the apple images (if that's the current object type)
Additionally, i'm working with cmake but i'm pretty sure that i don't have to include directories w/o any code.
So what's the problem here? Is my pathing wrong or does imread not work in subdirectories?
I appreciate any suggestions/solutions :)
Asked
Active
Viewed 3,772 times
0

Auberotte
- 221
- 1
- 6
- 14
-
Imread works in subdirectories. So I guess it's a pathing problem – Dimitri Mockelyn Aug 02 '13 at 14:37
-
I tried, putting the images in the same directory and than imread(m_object_type + "-" + buffer + ".jpeg") but that doesn't seem to work either. – Auberotte Aug 02 '13 at 14:54
1 Answers
5
Relative paths are relative to the process working directory. This is not necessarily the same as the directory in which the executable resides. So assuming you've got everything else right, then the most likely explanation is that your working directory is not the same as the directory in which the executable resides.
In any case, it sounds as though you want the program to locate the files in a directory relative to the executable. In which case you should not rely on the working directory and instead you will need to form the full path to the files. You'll just need to prepend the directory of the executable.

David Heffernan
- 601,492
- 42
- 1,072
- 1,490