OpenCV 2.0 C++ API using imshow: returns unhandled exception and “bad-flag”

后端 未结 6 1035
生来不讨喜
生来不讨喜 2020-12-07 02:08

I\'m trying to use the new OpenCV 2.0 API in MS Visual C++ 2008 and wrote this simple program:

cv::Mat img1 = cv::imread(\"image.jpg\",1);
cv::namedWindow(\"         


        
6条回答
  •  悲&欢浪女
    2020-12-07 02:58

    I had the same problem described above which turns out to be caused by the settings of the linker.

    I found the answer in another thread, OpenCV 2.3 and Visual Studio 2010.

    To repeat it here:

    Properties of your project (right click on it)

    • C/C++
      • General
        • include directory add the < your directory >\OpenCV2.3\include\opencv2, < your directory >\OpenCV2.3\include\opencv and < your directory >\OpenCV2.3\include
    • Linker

      • General
        • List item
      • Input
        • Add all the libs like opencv_core230d.lib opencv_highgui230d.lib and so on...

    Once I've done the above, I can run imshow and imread + all other cpp functions seamlessly! OP's problem has probably already been resolved, but hopefully this will be useful to other people who are led here looking for the same solution.

提交回复
热议问题