CPPOpenCV

Murtaza Hassan

4h上手C++版Opencv_哔哩哔哩_bilibili

数字图像处理(c++ opencv)入门学习 - 知乎 (zhihu.com)

Installing OpenCV on Windows for C++

Step 1 Download and Install OpenCV

Downloading and Installing OpenCV: Releases - OpenCV

2024年1月11日,最新版的OpenCV是4.9.0,我下载了的版本是OpenCV-4.8.0。下载解压到一个文件夹中。

1
2
3
4
5
6
7
8
9
(base) PS D:\Dev\opencv480> dir
目录: D:\Dev\opencv480
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2024/1/11 14:14 build
d----- 2024/1/11 14:14 sources
-a---- 2023/6/28 20:57 11560 LICENSE.txt
-a---- 2023/6/28 20:57 27913 LICENSE_FFMPEG.txt
-a---- 2023/6/28 20:57 868 README.md.txt

Step 2 Environment Variables

Add bin folder to Environment Variables path: D:\Dev\opencv480\build\x64\vc16\bin, then restart the PC.s

image-20240111171607051

Step3 New Visual Studio Project

  1. Best VS setting(Cherno)
  • Output Directory: $(SolutionDir)bin$(Platform)$(Configuration)\
  • Intermediate Directory: $(SolutionDir)bin\intermediate$(Platform)$(Configuration)\

D:\userCode\IntroOpenCV\bin\Win32\Debug\

D:\userCode\IntroOpenCV\bin\intermediate\Win32\Debug\

image-20240111172341038

  1. Set the platform target to x64

image-20240111172118484

Step 4 OpenCV configuration

Add Directories by going to Project-Properties-Configuration Properties

1
2
3
4
5
6
7
VC++ Directories
1. Add Build Directories: D:\Dev\opencv480\build\include
2. Add Library Directories: D:\Dev\opencv480\build\x64\vc16\lib
Linker Input
1. Add Linker input: opencv_world480d.lib
** d(opencv_world480d.lib) for debug
** without d(opencv_world480.lib) for release

image-20240111181709454

image-20240111181842738

Step 5 Test

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgcodecs.hpp>
#include <iostream>
#include <string>

int main()
{
std::string path = "./Resources/test.png";
cv::Mat img = cv::imread(path);
cv::imshow("Image", img);
cv::waitKey(0);
return 0;
}

CPPOpenCV
https://cosmicdusty.cc/post/Knowledge/CPPOpenCV/
作者
Murphy
发布于
2024年1月11日
许可协议