I want load a program demo of OpenCV using build files for x64, but always return me null, the function imread(...):
I use OpenCV 247 and only linker opencv_core247d.lib, opencv_highgui247d.lib
I use the OpenCV for Windows
>include: ...\opencv\build\include
>lib: ...\opencv\build\x64\vc10\lib
>bin: ...\opencv\build\x64\vc10\bin
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
if( argc != 2)
{
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}
Mat image;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR); // Read the file
if(! image.data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", image ); // Show our image inside it.
waitKey(0); // Wait for a keystroke in the window
return 0;
}
If you are passing the image path with a single backslash (\\) then opencv seems not to recognize the path.
Ex: Drive:\\folder1\\folder2\\imagename.extension
You might want to try with double backslash (\\\\) or forward slash (/). Ex:
Drive:\\\\folder1\\\\folder2\\\\imagename.extension
OR
Drive:/folder1/folder2/imagename.extension
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.