Unable to load an image - Open CV not working with Visual Studio2015
Hi guys,
I have just set up open cv3.1.0 with visual studio 2015 on windows 10. My simple code for loading the image is as under:
#include "opencv2\opencv.hpp"
using namespace cv;
int main(int argv, char** argc)
{
Mat test = imread("lena_color.jpg", CV_LOAD_IMAGE_UNCHANGED);
imshow("test", test);
waitKey();
}
When i build this code and run it, an empty image is momentarily displayed and I get this error in the terminal window
"OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow, file C:\buildslave64\win64_amdocl\master_PackSlave-win64-vc14-shared\opencv\modules\highgui\src\window.cpp, line 281"
I have placed my image in the active directory so i have no clue why it is not being accessed.
hi, i have tried the following modification too but it doesn't work. gives the same error :(
Mat test = imread("C:\Users\Tasie\Documents\Visual Studio 2015\Projects\opencvtest\lena_color.jpg", CV_LOAD_IMAGE_UNCHANGED);
try: imread("C:/Users/Tasie/Documents/Visual Studio 2015/Projects/opencvtest/lena_color.jpg"
Tried that too but did not work .gives this error : "OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow, file C:\build\2_4_winpack-build-win64-vc14\opencv\modules\highgui\src\window.cpp, line 261"
hey, could you get a meaningful size of this reading mat? if it's empty, it should be the problem of imread path.
why are there 2 different opencv versions in your error messages ?
@cbyzju I have modified the code to display the matrix as :
but the terminal window displays this:
which means the image is not being loaded. I have tried jpg and png formats for images and placed them in my working directory (in the visual studio project folder). no idea what else to try.
@berak I have tried different versions for OpenCV to see if any one of them works for me but got the same error msg for every version I tried.
if you run your prog from your ide, it will start in the debug (or relase folder), not in your project folder
@Tasie what did you change in the code to work?? or any other thing to be done?? and how did you run?
@Tasie what did you change in your code ? i have got same error please give me a solution