[Win8,CMake,OpenCV2] helloworld runtime errors when running in *Debug*

asked 2015-03-09 05:07:50 -0600

drtaglia gravatar image

Hello guys,

I am configuring a simple helloworld application in OpenCV under windows. I am using QtCreator with the NMAKE build system. When I specify "CMAKE_BUILD_TYPE=Release" in my CMakeLists.txt this little application works just fine:

#include <iostream>
#include <fstream>
#include "stdlib.h"
#include "opencv2/core/core.hpp"
#include "opencv2/core/types_c.h" ///< CV_RGB2GRAY
#include "opencv2/imgproc/imgproc.hpp" ///< cvtColor
#include "opencv2/highgui/highgui.hpp"

int main(int, char **) {
    cv::Mat image = cv::imread("input.png");
    std::cout << "image size: " << image.rows << " " << image.cols << std::endl;
    assert(image.rows > 0);
    assert(image.cols > 0);
    cv::cvtColor(image, image, CV_RGB2GRAY);
    cv::imshow("input", image);
    cv::waitKey(0);
    exit(0);
}

But when I specify CMAKE_BUILD_TYPE=Debug I get the following error:

Starting C:\Users\tagliasa\Developer\htrack\apps\helloworld_opencv-build\helloworld_opencv.exe...
image size: 0 0
Assertion failed: image.rows > 0, file C:\Users\tagliasa\Developer\htrack\apps\helloworld_opencv\main.cpp, line 12
C:\Users\tagliasa\Developer\htrack\apps\helloworld_opencv-build\helloworld_opencv.exe exited with code 3

In other OS's (Mac and Linux) everything works perfectly, but Win8+VS13 is giving me huge headaches.

Do you have any idea what might be causing this problem? Let me know if you need more information to help narrow down the issue.

Thanks for your help!

edit retag flag offensive close merge delete

Comments

I think that your problem is related with the path that you are giving to the source image. Try to give the absolute path.

theodore gravatar imagetheodore ( 2015-03-09 07:01:56 -0600 )edit