Opencv, undefined reference to `cv :: imread (?? cv :: String const & ???, int) '

I have a project in QT + Opencv, the code was working but I had to format windows and now I am trying to import the project again and this error appeared.

undefined reference to `cv :: imread (cv :: String const &, int) 'in this line:

 mat = cv::imread(path);

      

although my code looks like this:

 QString caminho = QFileDialog::getOpenFileName(this, tr("Open File"),
                                       "",
                                       tr("Images (*.png *.tiff)") );

 std::string path = caminho.toStdString();
 mat = cv::imread(path);

      

I tried other lines like "image.png" and didn't work.

Using OpenCV3, QT5.4, Mingw, Windows8.1

sorry my english

+3


source to share


1 answer


Two notes:

  • cv::imread

    It works with a string such as the C char *

    . This line is similar to what you tell openCV to open a file named "path". You have to change it to this: mat = cv::imread(path.c_str())

    and that's good!

  • undefined reference

    - this is when the compiler hasn't found an implementation of this function (ms just posted a link about it). GCC (MinGW) tries to see where the "imread" function is. Since you formatted your system, you will probably need to reset the "PATH" environment variable or some other configuration path. I recommend this reading: http://www.cs.swarthmore.edu/~newhall/unixhelp/howto_C_libraries.html , it explains why you need to do this.



Hope this helps!

+1


source







All Articles