Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

imread returns nothing

hello everyone,

I have been working on OpenCV 2.4.7 with Visual Studio 2012 express edition for quite a long time and it was working without any flaws. I recently upgraded to OpenCV 2.4.9 and given the path in the environment variables as mentioned. Then I tried running a sample program of loading images from a specific path with the include, library directories and the additional dependencies added to the project properties. The Mat is null even after the imread function. Then I tried upgrading to OpenCV 2.4.10 and its the same with this version too. Then I installed OpenCV 3.0.0, the sample code is working perfectly.

I am wondering why it was not working with OpenCV 2.4.9 and 2.4.10?

The problem was only with windows systems. I have tried in Windows 7 and Windows 8.1. In Linux it works perfectly. Since I tried all the solutions online, Can anyone tell me whats the problem? is it problem with the opencv 2.4.9? I can use 3.0.0 but I want some functions from 2.4.9, so I need to use 2.4.9. Please suggest mesome solution.

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
    Mat image;  
image = imread("C:\\Desktop\\Lighthouse.jpg", IMREAD_COLOR); 
    if( image.empty() )                      
    {
       cout <<  "Could not open or find the image" << std::endl ;
       return -1;
    }
    namedWindow( "Display window", WINDOW_AUTOSIZE ); 
    imshow( "Display window", image );                
    waitKey(0); 
    return 0;
}

In Environment Variables I added OPENCV_DIR = C:\OpenCV249\build and Path = %OPENCV_DIR%\x86\vc12\bin

In Project properties I have added Additional Include Directories = $(OPENCV_DIR)\include, Additional Library Directories = $(OPENCV_DIR)\x86\vc12\lib and

`Additional Dependencies = opencv_calib3d249.lib
                                         opencv_contrib249.lib
                                         opencv_core249.lib
                                         opencv_features2d249.lib
                                         opencv_flann249.lib
                                         opencv_gpu249.lib
                                         opencv_highgui249.lib
                                         opencv_imgproc249.lib
                                         opencv_legacy249.lib
                                         opencv_ml249.lib
                                         opencv_nonfree249.lib
                                         opencv_objdetect249.lib
                                         opencv_photo249.lib
                                         opencv_stitching249.lib
                                         opencv_ts249.lib
                                         opencv_video249.lib
                                         opencv_videostab249.lib
                                         opencv_superres249.lib
                                         opencv_ocl249.lib`

imread returns nothingempty Mat

hello everyone,

I have been working on OpenCV 2.4.7 with Visual Studio 2012 express edition for quite a long time and it was working without any flaws. I recently upgraded to OpenCV 2.4.9 and given the path in the environment variables as mentioned. Then I tried running a sample program of loading images from a specific path with the include, library directories and the additional dependencies added to the project properties. The Mat is null even after the imread function. Then I tried upgrading to OpenCV 2.4.10 and its the same with this version too. Then I installed OpenCV 3.0.0, the sample code is working perfectly.

I am wondering why it was not working with OpenCV 2.4.9 and 2.4.10?

The problem was only with windows systems. I have tried in Windows 7 and Windows 8.1. In Linux it works perfectly. Since I tried all the solutions online, Can anyone tell me whats the problem? is it problem with the opencv 2.4.9? I can use 3.0.0 but I want some functions from 2.4.9, so I need to use 2.4.9. Please suggest mesome solution.

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
    Mat image;  
image = imread("C:\\Desktop\\Lighthouse.jpg", IMREAD_COLOR); 
    if( image.empty() )                      
    {
       cout <<  "Could not open or find the image" << std::endl ;
       return -1;
    }
    namedWindow( "Display window", WINDOW_AUTOSIZE ); 
    imshow( "Display window", image );                
    waitKey(0); 
    return 0;
}

In Environment Variables I added OPENCV_DIR = C:\OpenCV249\build and Path = %OPENCV_DIR%\x86\vc12\bin

In Project properties I have added Additional Include Directories = $(OPENCV_DIR)\include, Additional Library Directories = $(OPENCV_DIR)\x86\vc12\lib and

`Additional Dependencies = opencv_calib3d249.lib
                                         opencv_contrib249.lib
                                         opencv_core249.lib
                                         opencv_features2d249.lib
                                         opencv_flann249.lib
                                         opencv_gpu249.lib
                                         opencv_highgui249.lib
                                         opencv_imgproc249.lib
                                         opencv_legacy249.lib
                                         opencv_ml249.lib
                                         opencv_nonfree249.lib
                                         opencv_objdetect249.lib
                                         opencv_photo249.lib
                                         opencv_stitching249.lib
                                         opencv_ts249.lib
                                         opencv_video249.lib
                                         opencv_videostab249.lib
                                         opencv_superres249.lib
                                         opencv_ocl249.lib`