VS2013 configures OpenCV3.4.0

First, there are Easter eggs at the end.

My laptop is installed with win7+ubuntu14.04 dual system. Recently, I want to use vs+opencv on windows to test some programs, because it is more convenient to use win to read the paper. I recently tried human body detection, using Yolo's method, which requires opencv version Above 3.4, so I had to reconfigure opencv.

Here I mainly refer to this blog

As for vs2013+opencv3.4.0, there will be many tutorials on Baidu. Here I mainly record the problems I encountered during the configuration process for future reference.

A Cmake tool to compile OpenCV source code

First, use the opencv source version (Sources) to download and unzip it on the opencv official website.


Then download the cmake link: https://cmake.org/files/v3.10/cmake-3.10.2-win64-x64.zip

Then put the decompressed file in the opencv folder created by yourself, and create the build folder used by cmake in the folder, which is named opencv-3.4.0_vs2013_x64 here, as shown in the following figure:


Then open cmake, double-click cmake-gui.exe under /bin to compile the opencv source code, select the path of the source code to select the path where the opencv source code is located, here my path is: E:\opencv-3.4.0\opencv- 3.4.0, the path to where to buid select the newly created build folder, here my path is: E:\opencv-3.4.0\opencv-3.4.0_vs2013_x64.

Click the Configure button to start compiling, and then some compilation options will be displayed as shown in the figure below. Most of the tutorials on the Internet recommend to uncheck the with_cuda option. I think that when installing opencv on Nvida jetson TX1, I also encountered the same problem with opencv and TX1 system. With the problem of cuda conflict, be sure to turn off compiling cuda in the cmake option, so here we also turn off with_cuda.


After clicking Configure again, configure done is displayed below, then click Generate, Gernerate done is displayed below, and then click Open Project to start vs2013. At this point, the compilation of opencv is completed.

Second configuration VS2013

After clicking the Open Project button, the open vs interface is shown in the figure below. I forgot to take a screenshot here, so I will use the pictures and steps of the blog to illustrate. The specific steps have been explained in great detail in this great article. This article configures opencv3.3.0. When configuring 3.4.0, the steps are basically the same.

What needs to be recorded here is that after completing the configuration according to the above steps, test the program to open the picture, and an error similar to the one shown below will appear:


Here we will need to copy all *d.dll files in the E:\opencv-3.4.0\opencv-3.4.0_vs2013_x64\bin\Debug path to the C:\Windows\System32 path, the pro test can solve the problem .


Next, when I test the program to open the image, I will encounter the following error: OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow


After searching on the Internet, I found the solution, that is, you need to add an absolute path before the image to be opened, even if the image is in the project folder. Attach the source code of the test program here:

#include<iostream>
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
using namespace cv;
using namespace std;
intmain()
{
	Mat image = imread("E:\\vsprogram\\Opencv3.4.0_TestDemo\\img.jpg",1);
	imshow("img", image);
	waitKey(0);

	return 0;
}

The test program runs successfully as shown in the following figure:


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325890450&siteId=291194637