安装opencv相关

Posted on 2021-01-23 15:12  yacbo  阅读(56)  评论(0编辑  收藏  举报

1.查看当前OpenCV的版本

pkg-config --modversion opencv

2.查找有关OpenCV文件

find / -iname "*opencv*"   //-i忽略大小写
find . -type d //查看当前下的目录
cp -a 保留原文件属性的前提下复制文件 
cp -r dirname(源文件) destdi(目标文件)

3.安装OpenCV

cd OpenCV*
mkdir
build cd build cmake .. make -j4 make install

 

4.卸载OpenCV

    ##然后进入~/Downloads/opencv3.3.1文件夹创建一个.cache文件夹,并拷贝相应的文件:

    cd ~/Downloads/opencv3.3.1

    ipp_file=ippicv_2017u3_lnx_intel64_general_20170822.tgz &&

    ipp_hash=$(md5sum ~/Downloads/$ipp_file | cut -d" " -f1) &&

    ipp_dir=.cache/ippicv &&

    mkdir -p ${ipp_dir} &&

    cp ~/Downloads/$ipp_file $ipp_dir/$ipp_hash-$ipp_file

rm -rf /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*

  

 5.示例

    /*test.cpp*/
    #include <opencv2/core/core.hpp>  
    #include <opencv2/highgui/highgui.hpp>  
    #include <opencv2/imgproc/imgproc.hpp>  

    int main(int argc,char *argv[])  
    {  
        cv::Mat image;  
        image=cv::imread("1.png");    
        cv::namedWindow("1.png");  
        cv::imshow("1.png",image);  
        cv::waitKey();  
        return 0;  
    }  
    g++ -g test.cpp `pkg-config --cflags --libs opencv` 

    ./a.out

  

Copyright © 2024 yacbo
Powered by .NET 9.0 on Kubernetes