这篇博客主要记录一下装好openCV和VS2013后如何建立一个基于openCV的项目。
一、新建项目
新建一个空项目。如下图:
二、添加库
2.1 VC++ Directoriese
在项目 -> 项目属性里
2.2 General
在项目 -> 项目属性 -> 链接器(Linker)-> 常规(General)
2.3 input
在项目 -> 项目属性 -> 链接器(Linker)-> 输入(input)
添加如下的库:
opencv_calib3d248d.lib
opencv_contrib248d.lib
opencv_core248d.lib
opencv_features2d248d.lib
opencv_imgproc248d.lib
opencv_flann248d.lib
opencv_highgui248d.lib
这些基本够用了
三、测试代码
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat image;
image = imread("C:/Users/chenguang/Desktop/a.pgn", IMREAD_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(); // Wait for a keystroke in the window
return 0;
}
四、添加dll
进行如上步骤后,可能会爆出如下错误:
'testnew.exe' (Win32): Loaded 'C:\Users\chenguang\Desktop\stitching\testnew\Debug\testnew.exe'. Symbols loaded.
'testnew.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'testnew.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Symbols loaded.
'testnew.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\kernel32.dll'
'testnew.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Symbols loaded.
'testnew.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'testnew.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120d.dll'. Cannot find or open the PDB file.
'testnew.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp120d.dll'. Symbols loaded.
'testnew.exe' (Win32): Loaded 'E:\soft\openCV\opencv\build\x86\vc12\bin\opencv_core248d.dll'. Cannot find or open the PDB file.
'testnew.exe' (Win32): Loaded 'E:\soft\openCV\opencv\build\x86\vc12\bin\opencv_highgui248d.dll'. Cannot find or open the PDB file.
'testnew.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Symbols loaded.
'testnew.exe' (Win32): Loaded 'C:\Windows\SysWOW64\win32u.dll'. Symbols loaded.
'testnew.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Symbols loaded.
'testnew.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32full.dll'. Cannot find or open the PDB file.
'testnew.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Cannot find or open the PDB file.
The thread 0x158 has exited with code -1073741510 (0xc000013a).
The thread 0x9cc has exited with code -1073741510 (0xc000013a).
The thread 0x2e90 has exited with code -1073741510 (0xc000013a).
The thread 0x7e8 has exited with code -1073741510 (0xc000013a).
The program '[14932] testnew.exe' has exited with code -1073741510 (0xc000013a).
解决方法:
1、点 调试
2、然后 选项和设置
3、右边勾上 启用源服务器支持
4、左边点 符号
5、把微软符号服务器勾
6、运行的时候等一下 莫慌!!
7、问题解决