官术网_书友最值得收藏!

Windows

To keep things easy, let's install OpenCV using pre-built libraries. Go to opencv.org and download the latest version for Windows. The current version is 4.0.0, and you can get the download link from the OpenCV homepage. You should make sure you have admin rights before you proceed.

The downloaded file will be an executable file, so just double-click on it to start the installation. The installer expands the content into a folder. You will be able to choose the installation path, and check the installation by inspecting the files.

Once you are done with the previous step, we need to set the OpenCV environment variables and add them to the system path to complete the installation. We will set up an environment variable that will hold the build directory of the OpenCV library. We will be using this in our projects.

Open up the Terminal and type the following:

C:> setx -m OPENCV_DIR D:OpenCVBuildx64vc14
We are assuming that you have a 64-bit machine with Visual Studio 2015 installed. If you have Visual Studio 2012, replace vc14 with vc11 in the command. The path specified is where we would have our OpenCV binaries, and you should see two folders inside that path called lib and bin. If you are using Visual Studio 2018, you should compile OpenCV from scratch.

Let's go ahead and add a path to the bin folder to our system path. The reason we need to do this is because we will be using the OpenCV library in the form of dynamic link libraries (DLLs). Essentially, all the OpenCV algorithms are stored here, and our operating system will only load them during runtime.

In order to do that, our operating system needs to know where they are located. The PATH system variable contains a list of all the folders where it can find DLLs. So, naturally, we need to add the path of the OpenCV library to this list.

Why do we need to do all this? Well, the other option is to copy the required DLLs in the same folder as the application's executable file (.exe file). This is an unnecessary overhead, especially when we are working with many different projects.

We need to edit the PATH variable to add this folder. You can use software such as Path Editor to do this, which you can download from here: https://patheditor2.codeplex.com. Once you install it, start it up and add the following new entry (you can right-click on the path to insert a new item):

%OPENCV_DIR%bin

Go ahead and save it to the registry. We are done!

主站蜘蛛池模板: 闻喜县| 武汉市| 沙洋县| 高要市| 兴海县| 乳山市| 密云县| 且末县| 元阳县| 游戏| 罗平县| 翼城县| 大悟县| 白河县| 乌鲁木齐市| 洛阳市| 雷山县| 嘉祥县| 台湾省| 绍兴县| 伊金霍洛旗| 仁化县| 鄯善县| 剑河县| 新丰县| 浦县| 太湖县| 富平县| 平乐县| 富阳市| 北辰区| 株洲市| 凌源市| 华容县| 丽江市| 龙川县| 乌拉特前旗| 尤溪县| 密云县| 田东县| 临猗县|