带VS的OpenCV程序x64

时间:2014-02-13 20:20:17

标签: opencv 64-bit

我想使用x64的构建文件加载OpenCV的程序演示,但总是返回null,函数imread(...):

我使用OpenCV 247,只使用链接器opencv_core247d.lib,opencv_highgui247d.lib

我使用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;
}

1 个答案:

答案 0 :(得分:0)

如果使用单个反斜杠(\)传递图像路径,则opencv似乎无法识别路径。

例如:云端硬盘:\ folder1 \ folder2 \ imagename.extension

您可能希望尝试使用双反斜杠(\\)或正斜杠(/)。 例如:

驱动器:\\ folder1中\\文件夹2 \\ imagename.extension

OR

驱动器:/folder1/folder2/imagename.extension