0

I use imread() function to read tif image, but the returned Mat is empty.

vector<Mat> imgs;
int num = 10;
for (int i = 1; i <= num; i++) {
    char buffer_s[200];
    sprintf(buffer_s, "img%02d.jpg",i);
    Mat buffer_img = imread(buffer_s);
    if (buffer_img.empty()) {
        cout << buffer_s << " read incorrectly" << endl;
        return -1;
    }
    imgs.push_back(buffer_img);

}

The images to be read are under the project directory. I also tried to use the absolute path but the outcome was the same. Here is the debug interface:enter image description here

I can't figure it out.

Zhang
  • 79
  • 12
  • Just to be sure: what's the output ? – Jabberwocky Mar 06 '17 at 13:47
  • Sorry that I didn't make it clear. The program doesn't report a error and the output is the message that I write in cout. And I find a solution here http://stackoverflow.com/questions/2584273/issue-with-reading-an-image-using-cvimread-function-in-opencv?rq=1 – Zhang Mar 06 '17 at 13:57
  • But another problem is that when I changed the *.lib to *d.lib in Debug-Microsoft.Cpp.Win32.user, it also changed to *d.lib in Release label. How can I solve this ? – Zhang Mar 06 '17 at 14:00
  • 1
    That's another unrelated question. Please ask a new question concerning that question. – Jabberwocky Mar 06 '17 at 14:01
  • ***I also tried to use the absolute path*** Did you properly escape your \ characters? – drescherjm Mar 06 '17 at 14:46
  • ***function to read tif image*** But the files are named `.jpg`?? If they are really tiff they should not have a `.jpg` extension. Maybe you have the "hide extensions for known types" turned on in your OS and you are not using the correct extension because windows thinks it is simplifying things for you by hiding the extension. – drescherjm Mar 06 '17 at 14:47
  • tiff files have an extension of `tif` – Jeru Luke Mar 06 '17 at 14:59
  • Sorry again for that, a jpg extension results from my attempt of finding out whether jpeg file works. The pictures with same name in both tif and jpg extension exist at the same path. And I use "\" in this way : "c:\\usr\\***\\img.tif", thought there's no problem. The empty Mat is because I mixed *.d.lib(for debug) and *.lib(for release). – Zhang Mar 07 '17 at 01:08

0 Answers0