deepin + clion + opencv环境搭建及创建工程
Posted navysummer
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了deepin + clion + opencv环境搭建及创建工程相关的知识,希望对你有一定的参考价值。
1.安装依赖
[compiler] sudo apt-get install build-essential [required] sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev [optional] sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
2.下载opencv源码
navy@DEEPIN:~/Desktop$ mkdir workspace
navy@DEEPIN:~/Desktop$ cd workspace git clone https://github.com/opencv/opencv.git git clone https://github.com/opencv/opencv_contrib.git git clone https://github.com/opencv/opencv_extra.git
3.使用cmake编译源码
navy@DEEPIN:~/Desktop/workspace$ mkdir build navy@DEEPIN:~/Desktop/workspace$ cd build navy@DEEPIN:~/Desktop/workspace/build$ cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ../opencv navy@DEEPIN:~/Desktop/workspace/build$ make -j7 navy@DEEPIN:~/Desktop/workspace/build$ sudo make install
4.其他根据需要安装
5.使用clion创建基于opencv的项目
6.修改CMakeLists.txt文件
7.源码编写
附源码
CMakeLists.txt文件
cmake_minimum_required(VERSION 3.9.5) project(test) set(CMAKE_CXX_STANDARD 14) set(OpenCV_DIR "/home/navy/Desktop/workspace/build") find_package(OpenCV REQUIRED) include_directories(${OpenCV_INCLUDE_DIRS}) add_executable(test main.cpp) set(OpenCV_LIBS opencv_core opencv_imgproc opencv_highgui opencv_imgcodecs) target_link_libraries(test ${OpenCV_LIBS})
main.cpp文件
#include<opencv2/opencv.hpp> #include <iostream> #include <math.h> using namespace cv; int main(){ Mat src = imread("/home/navy/Desktop/workspace/opencv_extra/testdata/gpu/caltech/image_00000009_0.png",0); if(src.empty()){ printf("load fail "); } namedWindow("test"); imshow("test",src); waitKey(0); return 0; }
以上是关于deepin + clion + opencv环境搭建及创建工程的主要内容,如果未能解决你的问题,请参考以下文章