Clion + OPENCV Environment Building (experience the best C + + IDE)

Source: Internet
Author: User

Objective:

  A good development environment, is the program Ape Dream, for the development of OPENCV, has always felt that vs although too big, so later with the codeblocks, and then feel that both the VS or codeblocks are not beautiful, code hints are not very good, the configuration is also very cumbersome. Then, I was on the Internet to search the use of the C + + IDE, this does not, caught Clion, has been very nostalgic for the web development when the IntelliJ idea, the clion is also from the JetBrains family, so beautiful aspect can be impeccable. Let's start building it.

Build:

  1, download down the latest 2016.3.3 version of Clion, very simple, the default installation.

2, MinGW compiler, download a green version of the Internet, I use the minGW3.20 version, unzip somewhere, open clion in the setting when the compiler to choose the directory on the line

3, need to compile OpenCV with MinGW, refer to my other article Codeblocks + OpenCV + Cmake + MinGW Environment building (once-in-a-time version)

Sample project:

 Create a new project Hello, just configure the CMake list file, and then write a simple code to display Lena in Main.cpp.

  

Cmake_minimum_required (VERSION3.6) Project (hello)Set(Cmake_cxx_standard One) # contains directory include_directories (c:\\\\opencv\\\\include) include_directories (C:\\\\OPENCV\\\\INCLUDE\\\\OPENCV) Include_directories (C:\\\\OPENCV\\\\INCLUDE\\\\OPENCV2) # source fileSet(Source_files main.cpp) # MinGW compiling OpenCV DLL.A librarySet(Target_libs"C:\\\\OPENCV\\\\LIB\\\\LIBOPENCV_CORE244.DLL.A"        "C:\\\\OPENCV\\\\LIB\\\\LIBOPENCV_HIGHGUI244.DLL.A"        "C:\\\\OPENCV\\\\LIB\\\\LIBOPENCV_IMGPROC244.DLL.A") add_executable (Hello ${source_files}) target_link_libraries (Hello ${target_libs})
CmakeList.txt
#include <iostream># include<opencv2/core/core.hpp># include<opencv2/highgui/highgui.hpp># include<opencv2/imgproc/imgproc.hpp>using namespaceCV;using namespacestd;intMain () {Mat img= Imread (".. /lena.png"); Resize (img,img,size ( -, -)); Imshow ("img", IMG);    Waitkey ();    Destroyallwindows (); return 0;}
main.cpp

In fact, here is the most important Cmakelist.txt configuration, this step simplifies the configuration, no longer like VS and Codeblocks 1.1 points to choose the Library directory and contains the directory, it is very convenient.

Here is a question to note, clion with CMake to manage the compilation of the program build and run, EXE generated under CMake, so the Lena file in the code needs to use ". /lena.png "for normal access.

OK, so you can use Clion to write OPENCV image program, the experience is very good.

Clion + OPENCV Environment Building (experience the best C + + IDE)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.