CodeBlocks configures the VS2013 compiler and runs OpenCV

CodeBlocks configures VS2013 and runs OpenCV

The CodeBlocks version used here is 16.01, and the OpenCV version is 2.4.13, which can be downloaded and installed directly from Baidu’s official website.
Open the Settings->Compiler of CodeBlocks, select Microsoft Visual C++ 2010 for the Selected compiler, click Set as default, and change the paths in the following setting items to the corresponding paths in the VS installed by yourself. What needs to be set are: Microsoft SDKs \Windows\v7.1A, VC and Common7\IDE.
You can copy the relevant files in VS, so you don't need to install VS in the future!
The extraction is as follows:
Write picture description here
the settings are as follows:
Write picture description hereWrite picture description here
click OK, and the configuration is complete!
Next, you can create a new project to test, File->New->Project->Console application. Compile and run the HelloWorld program in Release mode.

If the above is successful, then start to configure the project's dependence on opencv.
Right-click on the newly created project and select Build options to configure the Release item.
Compiler in Search directories needs to include the header files in opencv, and Linker needs to specify the library directory. Add all the lib files of opencv in the Linker settings. There are two versions of Debug and Release. The version without d at the end of the name is Release. You only need to choose this type. Of course, you can select all of them if you find it troublesome. Note that the directory selection is build/x86/vc12/lib!
Write picture description here
Write picture description here
Write picture description here
Click OK, and the project is configured. The next important step is to configure environment variables. You need to add build/x86/vc12/bin to the system Path, otherwise an error will occur after compiling and running!

Finally, copy the code below to test the camera.

#include <opencv2\opencv.hpp>
using namespace cv;

void main()
{
    VideoCapture cap(1);
    if (!cap.isOpened())
    {
        return;
    }
    Mat frame;
    while (1)
    {
        cap >> frame;
        imshow("当前视频", frame);
        waitKey(10);
    }
}

Write picture description here

Guess you like

Origin blog.csdn.net/CanvaChen/article/details/52549283