vs2019社区版、win10 64位操作系统
1、下载OpenCV4.3.0,官网为opencv.org
2、安装opencv,我的安装目录是 E:\opencv
3、添加环境变量,在PATH中添加: E:\opencv\opencv\build\x64\vc15\bin
4、将E:\opencv\opencv\build\x64\vc15\bin目录下面的
opencv_world430.dll和opencv_world430d.dll文件复制到
C:\Windows\SysWOW64这个文件夹;
另外:以上如果不想copy到C盘,把两个文件添加到工程的引用中应该也是可行的(还没有尝试过);
5、将bin目录里面的opencv_ffmpeg341_64.dll复制到C:\Windows\System32这个文件夹;
1、包含目录中加入
E:\opencv\opencv\build\include;E:\opencv\opencv\build\include\opencv2;
2、库目录中加入 E:\opencv\opencv\build\x64\vc15\lib;
3、 链接器->输入->附加依赖项中加入opencv_world430d.lib
四、测试代码
//建立一个C++控制台程序即可
// opencvDemo.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include "pch.h"
#include
#include
#include
#include
using namespace cv;
using namespace std;
int main()
{
Mat image;
image = imread("E:\\test.jpg"); // 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
std::cout << "Hello World!\n";
}
// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单
// 入门提示:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件
最后一步:链接器——输入——附加依赖项
opencv_aruco410d.lib
opencv_bgsegm410d.lib
opencv_bioinspired410d.lib
opencv_calib3d410d.lib
opencv_ccalib410d.lib
opencv_core410d.lib
opencv_datasets410d.lib
opencv_dnn410d.lib
opencv_dnn_objdetect410d.lib
opencv_dpm410d.lib
opencv_face410d.lib
opencv_features2d410d.lib
opencv_flann410d.lib
opencv_fuzzy410d.lib
opencv_gapi410d.lib
opencv_hfs410d.lib
opencv_highgui410d.lib
opencv_imgcodecs410d.lib
opencv_imgproc410d.lib
opencv_img_hash410d.lib
opencv_line_descriptor410d.lib
opencv_ml410d.lib
opencv_objdetect410d.lib
opencv_optflow410d.lib
opencv_phase_unwrapping410d.lib
opencv_photo410d.lib
opencv_plot410d.lib
opencv_quality410d.lib
opencv_reg410d.lib
opencv_rgbd410d.lib
opencv_saliency410d.lib
opencv_shape410d.lib
opencv_stereo410d.lib
opencv_stitching410d.lib
opencv_structured_light410d.lib
opencv_superres410d.lib
opencv_surface_matching410d.lib
opencv_text410d.lib
opencv_tracking410d.lib
opencv_video410d.lib
opencv_videoio410d.lib
opencv_videostab410d.lib
opencv_world410d.lib
opencv_xfeatures2d410d.lib
opencv_ximgproc410d.lib
opencv_xobjdetect410d.lib
opencv_xphoto410d.lib