zoukankan      html  css  js  c++  java
  • Windos Linux(CentOS 7) opencv安装 tar.gz文件安装

    前提: 版本为4.4.0 

      下载地址:https://github.com/opencv/opencv/releases

    windows 下载.exe 安装之后

    复制2个文件: buildjavaopencv-440.jar,  buildjavax64opencv_java440.dll

    调用列子如下:

                    // windows 版本
                    URL url = ClassLoader.getSystemResource("lib/opencv_java440.dll");
                    logger.info("动态库:" + url.getPath());
                    System.load(url.getPath());
    
                    // 读取图像
                    Mat img = imread("E:\TEST\opencv\before.png", Imgcodecs.IMREAD_GRAYSCALE);
                    Mat new_img = new Mat();
                    Core.bitwise_not(img, new_img);
                    Imgproc.blur(new_img, img, new Size(3, 3));
    
                    Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(3, 3));
                    Imgproc.dilate(img, new_img, kernel);
                    Imgproc.erode(new_img, img, kernel);
                    Core.bitwise_not(img, new_img);
                    Imgcodecs.imwrite("E:\TEST\opencv\after.png", new_img);

    linux  

    1:wget 下载 opencv文件

    参考: https://www.jianshu.com/p/744269985eea

    下载解压

    wget https://github.com/opencv/opencv/archive/4.4.0.zip
    unzip 4.4.0.tar.gz

    进入目录

    cd opencv-4.4.0

    创建build目录 并进入

    mkdir build && cd build

    设置make参数 前提已经安装cmake(可参考最下面).

    cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
    make
    make install

    生成jar

    cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -DBUILD_TESTS=OFF ..
    make -j8
    make install

     此时2个文件: build/bin/opencv-java440.jar   build/lib/libopencv_java440.so 

    注意,此Linux生产的opencv-440.jar 和windows安装产生的opencv-java440.jar一样

    提示目前的cmake版本过低 cmake 版本升

    cmake时报错: CMake 3.8 or higher is required.  You are running version 3.5.1

    参考:  https://www.cnblogs.com/jsdy/p/12689470.html

    1: cmake 升级

    1. 查看当前cmake版本:

    cmake -version

    2. 卸载当前cmake:(如果安装了ROS跳过此步

    yum remove cmake

    3. 下载cmake:

      可直接从cmake官网下载新版本,也可执行如下语句:

    wget http://www.cmake.org/files/v3.16/cmake-3.16.6.tar.gz

    安装cmake前 , 否则./bootstrap 提示g++ Nopackage

    yum -y install gcc-c++ openssl-devel 

    若提示错误

    -- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR) 
    CMake Error at Utilities/cmcurl/CMakeLists.txt:454 (message):
      Could not find OpenSSL.  Install an OpenSSL development package or
      configure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL.
    
    
    -- Configuring incomplete, errors occurred!
    See also "/root/soft/cmake-3.16.6/CMakeFiles/CMakeOutput.log".
    See also "/root/soft/cmake-3.16.6/CMakeFiles/CMakeError.log".
    ---------------------------------------------
    Error when bootstrapping CMake:
    Problem while running initial CMake

    执行安装

    yum install openssl-devel 
  • 相关阅读:
    5.搜索-dfs、回溯、bfs
    4.排序算法
    3.二分查找
    2.双指针
    1.贪心算法
    【目录】leetcode刷题
    深度学习的优化与正则化
    什么是深度学习
    循环神经网络
    Failed to execute 'index' on 'IDBObjectStore': The specified index was not found.
  • 原文地址:https://www.cnblogs.com/eason-d/p/14597849.html
Copyright © 2011-2022 走看看