• (转载)ubuntu卸载opencv并重装opencv3.0.0


    ubuntu卸载opencv并重装opencv3.0.0
    一、 卸载opencv2.4.9: Going to the "build" folder directory of opencv from terminal, and execute the following:

    1. $ sudo make uninstall
    2. $ cd ..
    3. $ sudo rm -r build
    4. $ sudo rm -r /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV /usr/local/bin/opencv* /usr/local/lib/libopencv*

    这一步可能有error
    下面执行如下操作:
    5. sudo apt-get –purge remove opencv-doc opencv-data python-opencv

    二、 安装opencv,去CSDN下载opencv3.0.0和ippicv_linux_20141027.tgz(http://download.csdn.net/detail/yunlong782/8940743)。

    install essential packages
    [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

    使用cmake-gui安装,首先安装cmake和cmake-qt-gui

    1. $ sudo apt-get install cmake cmake-qt-gui
    2. 解压opencv3.0.0,并进入目录,建立build目录并进去build目录打开终端,并输入:$ cmake-gui
    3. 在source 目录里添加:文件目录如(../../../opencv-3.0.0.0-beta),在build目录添加build目录(如:../../../opencv-3.0.0.0-beta/build),在CUDA_GENERATION 选择Kepler(我的显卡型号:gtx 980m)
    4. configure,此时会处错误,原因是由于ippicv_linux_20141027.tgz不正确。把下载好的ippicv_linux_20141027.tgz替换掉出错路径下的ippicv_linux_20141027.tgz即可。重新configure
    5. generate
    6. 进入build目录 $ make -j8
      7.在build目录下 $ sudo make install
    7. 写入opencv路径:sudo sh -c 'echo "usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
    8. sudo ldconfig

    三、测试opencv是否装好

    1.创建工作目录
    $ mkdir ~/opencv-lena
    $ cd ~/opencv-lena
    $ gedit DisplayImage.cpp

    1. 编译如下代码
    #include <stdio.h>
    #include <opencv2/opencv.hpp>
    using namespace cv;
    int main(int argc, char** argv )
    {
    	if ( argc != 2 )
    	{
    		printf("usage: DisplayImage.out <Image_Path>
    ");
    		return -1;
    	}
    	Mat image;
    	image = imread( argv[1], 1 );
    	if ( !image.data )
    	{
    		printf("No image data 
    ");
    		return -1;
    	}
    	namedWindow("Display Image", WINDOW_AUTOSIZE );
    	imshow("Display Image", image);
    	waitKey(0);
    	return 0;
    }
    
    1. 创建CMake文件
      $ gedit CMakeLists.txt
      写入如下内容
    cmake_minimum_required(VERSION 2.8)
    project( DisplayImage )
    find_package( OpenCV REQUIRED )
    add_executable( DisplayImage DisplayImage.cpp )
    target_link_libraries( DisplayImage ${OpenCV_LIBS} )
    
    1. 编译
    $ cd ~/opencv-lena
    $ cmake .
    $ make
    
    1. 执行
        此时opencv-lena文件夹中已经产生了可执行文件DisplayImage,下载lena.jpg放在opencv-lena下,运行

      $ ./DisplayImage lena.jpg

    1. 结果
  • 相关阅读:
    nodejs日志管理log4js
    js数组去重的几种方法
    Echarts同一页面多个图表自适应浏览器窗口大小——window.onresize
    Echarts自适应浏览器大小
    [原创]Nodejs 远程执行linux shell
    ssh无需密码登录linux服务器
    Nodejs mysql pool使用实例
    Activity基础知识
    最大熵模型介绍
    node-sass element-plus 安装失败
  • 原文地址:https://www.cnblogs.com/pprp/p/9471203.html
Copyright © 2020-2023  润新知