OpenCV不适用于Visual Studio
我刚刚安装了openCV版本.我的计算机上安装了3.00 beta版,我正在尝试使用VS2013对其进行测试.我遵循了快速入门指南:
I just installed openCV ver. 3.00 beta on my computer and I'm trying to test it with VS2013. I followed quick start guide:
1)针对Windows的安装,使用-构建库.
1) Installation for windows, using pre-build libraries.
2) Microsoft VS 中的OpenCV,使用本地方法和库的x64/vc12
目录.
2) OpenCV inside Microsoft VS, using local method and x64/vc12
directory for libraries.
结果,他们的示例(在链接2中列出)产生了错误:
As a result, their example(listed in link #2) produced an error:
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/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], IMREAD_COLOR); // Read the file
if (image.empty()) // 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>------ Build started: Project: test_openCV, Configuration: Debug Win32 ------
1>LINK : fatal error LNK1104: cannot open file 'opencv_calib3d300d.lib'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
据我了解,我的程序可以看到openCV库,但是由于某种原因无法打开它们.请帮忙.
As far as I understand, my program can see openCV libraries, but for some reason cannot open them. Please help.
谢谢
更新:尝试执行前四个注释中建议的操作,但仍然没有结果.因此,我将在此处发布完整信息:
Update: Tried to do what was recommended in first four comments, no result still. So I will post here full information:
项目:CUDA 6.5(我需要使用CUDA).
Project: CUDA 6.5 (I need to work with CUDA).
源文件:Source.cpp
模式:调试,x64.
环境变量:
OPENCV_DIR: C:\programs\misha\opencv\build\x64\vc12
Path (the last string): %OPENCV_DIR%\bin
页面属性:
C\C++ -> General -> Additional Include Directories(last string):
$(OPENCV_DIR)\..\..\include
Linker -> General -> Additional Library Directories(last string):
$(OPENCV_DIR)\lib
Linker -> Input -> Additional Dependencies:
opencv_calib3d300d.lib
opencv_core300d.lib
opencv_features2d300d.lib
opencv_flann300d.lib
opencv_highgui300d.lib
opencv_imgcodecs300d.lib
opencv_imgproc300d.lib
opencv_ml300d.lib
opencv_objdetect300d.lib
opencv_photo300d.lib
opencv_shape300d.lib
opencv_stitching300d.lib
opencv_superres300d.lib
opencv_ts300d.lib
opencv_video300d.lib
opencv_videoio300d.lib
opencv_videostab300d.lib
输出:
1>------ Build started: Project: test_openCV, Configuration: Debug x64 ------
1>LINK : fatal error LNK1104: cannot open file 'opencv_calib3d300d.lib'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
因此,由于某种原因,我无法构建x64项目.错误是一样的.
So, I cannot build x64 project for some reason. Error is the same.
更新2:如果您可以构建此示例(或任何带有OpenCV的示例),请发送至genkin@physics.msu.ru吗?我会自己弄清楚的
After a long time of different attempts, I found the answer here. For x64
project, in addition to what I did above, you have to:
1)设置环境变量后,重新启动PC.变量路径没有重新启动就没有在我的计算机上更新.
1) Restart your PC after setting enviromental variables. Variable Path was not updated on my computer without restart.
2)除了上面添加的库之外,您还必须添加(尽管对于本示例来说,其中一些可能未使用):
2) In addition to libraries added above, you have to add (although, for this example some of them might not be used):
ippicvmt.lib
IlmImfd.lib
libtiffd.lib
libpngd.lib
libjasperd.lib
libjpegd.lib
libwebpd.lib
zlibd.lib
comctl32.lib
我最近不得不在新PC上再次安装它.正如user1060873所指出的,您只需要添加$ OPENCV $/lib文件夹中的库.例如,在我的PC上是C:\opencv\build\x64\vc12\lib
.请注意,对于调试模式,您应该添加opencv_world310d.lib
,对于版本opencv_world310.lib
I recently had to install it again on a new PC. As user1060873 pointed out, you have to add only the libraries located in your $OPENCV$/lib folder. For example, on my PC it is C:\opencv\build\x64\vc12\lib
. Note, that for debug mode you should add opencv_world310d.lib
, and for release opencv_world310.lib