码迷,mamicode.com
首页 > 其他好文 > 详细

deepin + clion + opencv环境搭建及创建工程

时间:2020-01-29 16:00:14      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:nim   bash   main   jpeg   ace   mes   fail   iba   test   

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\n");
    }
    namedWindow("test");
    imshow("test",src);
    waitKey(0);
    return 0;
}

  

deepin + clion + opencv环境搭建及创建工程

标签:nim   bash   main   jpeg   ace   mes   fail   iba   test   

原文地址:https://www.cnblogs.com/navysummer/p/12240334.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!