简体   繁体   English

在 Visual C++ 中配置 openCV 库的困难

[英]Difficulties configuring openCV library in Visual C++

I'm trying to configure my Visual C++ to use the openCV libraries.我正在尝试将我的 Visual C++ 配置为使用 openCV 库。 I've followed the instructions on OpenCV website http://opencv.willowgarage.com/wiki/VisualC%2B%2B ...我已按照 OpenCV 网站http://opencv.willowgarage.com/wiki/VisualC%2B%2B ...

// OpenCV_Helloworld.cpp : Defines the entry point for the console application.
// Created for build/install tutorial, Microsoft Visual Studio and OpenCV 2.2.0

#include "stdafx.h"

#include <cv.h>
#include <cxcore.h>
#include <highgui.h>

int _tmain(int argc, _TCHAR* argv[])
{
        // Open the file.
        IplImage *img = cvLoadImage("photo.jpg");
        if (!img) {
                printf("Error: Couldn't open the image file.\n");
                return 1;
        }

        // Display the image.
        cvNamedWindow("Image:", CV_WINDOW_AUTOSIZE);
        cvShowImage("Image:", img);

        // Wait for the user to press a key in the GUI window.
        cvWaitKey(0);

        // Free the resources.
        cvDestroyWindow("Image:");
        cvReleaseImage(&img);

        return 0;
}

I have altered the include and library directories in VC++ directories inside the Property Pages, and have added the additional dependencies.我已经更改了属性页内 VC++ 目录中的 include 和 library 目录,并添加了其他依赖项。 However, when I try and load an image with the same header files as the sample code, it says that cvLoadImage is undefined, as is cvNamedWindow但是,当我尝试使用与示例代码相同的 header 文件加载图像时,它表示 cvLoadImage 未定义,cvNamedWindow 也是如此

IplImage *img = cvLoadImage("JellyFish.jpg");

Any suggestions as to where I might have my problem?关于我可能在哪里遇到问题的任何建议?

You might try making sure your Code Generation for your project is Multi-threaded DLL (or Multi-threaded Debug DLL).您可以尝试确保您的项目的代码生成是多线程 DLL(或多线程调试 DLL)。

You need to configure using CMake.您需要使用 CMake 进行配置。 Get OpenCV 2.2 and try the following step by step guide.获取 OpenCV 2.2 并尝试以下分步指南。

http://kaushalsolanki.com/2011/01/compile-and-set-up-opencv-for-visual-studio-2010-with-64-bits-support-ipp-7-0-and-tbb/ http://kaushalsolanki.com/2011/01/compile-and-set-up-opencv-for-visual-studio-2010-with-64-bits-support-ipp-7-0-and-tbb/

I encountered the same error but i finally fixed it I am using opencv 2.3 what I did was I changed all the additional dependencies from opencv_core220d.lib to opencv_core231d.lib we need to change all of the dependencies in the same way我遇到了同样的错误,但我终于修复了它我正在使用 opencv 2.3 我所做的是将所有额外的依赖项从 opencv_core220d.lib 更改为 opencv_core231d.lib 我们需要以相同的方式更改所有依赖项

and then i copied all the *.dll files from my bin>>debug folder to where i had new project that is helloworld>>helloworld然后我将所有 *.dll 文件从我的 bin>>debug 文件夹复制到我有新项目 helloworld>>helloworld 的位置

for example C:\opencv\build\bin\debug copy all *.dll files to C:\opencv\Projects\helloworld\helloworld例如 C:\opencv\build\bin\debug 将所有 *.dll 文件复制到 C:\opencv\Projects\helloworld\helloworld

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM