• 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;
    }
    

      

  • 相关阅读:
    window端口被占用
    webstorm中关闭烦人Eslint语法检查
    STM32 printf 函数原型
    Memset、Memcpy、Strcpy 的作用和区别(转)
    SMD贴片元件的封装尺寸(转)
    Windows Phone开发工具初体验(转载)
    Open Cell(转载)
    标题:常用贴片元件封装(转载)
    关于TV Dongle的功能设计和思考【图】(转载)
    图片预览加上传遇到的一系列问题
  • 原文地址:https://www.cnblogs.com/navysummer/p/12240334.html
Copyright © 2020-2023  润新知