【美高梅手机版4858】linux下编写翻译opencv

By admin in 美高梅手机版4858 on 2019年3月26日

1、安装cmake:sudo apt-get install cmake

## 注重项& 环境搭建

“`

【美高梅手机版4858】linux下编写翻译opencv。    sudo apt-get install build-essential cmake pkg-config

    sudo apt-get install cmake git libgtk2.0-dev pkg-config
libavcodec-dev libavformat-dev libswscale-dev

    sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev
libjpeg-dev libpng-dev libtiff5-dev libjasper-dev libdc1394-22-dev

“`

– [参考网站] :

– [libjasper-dev] :

    “`

    sudo aptitude install python-opencv

    – perl: warning: Setting locale failed

    export LC_ALL=C 

    “`

    from:

## 获取opencv 源代码

– 源代码下载 :

## 编写翻译源代码

### 进入opencv源代码目录,在该目录中新建一个名为release的文本夹。

    “`

    cd ~/opencv/opencv-2.4.9

    mkdir release

    cd release

    “`

   
使用cmake工具在该文件夹中生成makefile文件,钦定opencv的装置目录为/usr/local,opencv的源代码位于上一层目录。

    “`

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

    “`

### 倘诺cmake阶段平素停在下载IPPICV那里,则按Ctrl C撤消

    手动下载ippicv_2017u3_lnx_intel64_general_20170822.tgz

   

###
然后进入~/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

    “`

### 然后再行运维编写翻译命令和安装命令:

    “`

    cd ~/Downloads/opencv3.3.1/build

    sudo cmake -D CMAKE_BUILD_TYPE=DEBUG -D
CMAKE_INSTALL_PREFIX=/usr/local ..

  sudo make

    sudo make install

    “`

    sudo apt-get install build-essential cmake pkg-config

    sudo apt-get install cmake git libgtk2.0-dev pkg-config
libavcodec-dev libavformat-dev libswscale-dev

    sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev
libjpeg-dev libpng-dev libtiff5-dev libjasper-dev libdc1394-22-dev

    “`

– [参考网站] :

– [libjasper-dev] :

    “`

    sudo aptitude install python-opencv

    perl: warning: Setting locale failed

    export LC_ALL=C 

    “`

    from:

## 获取opencv 源代码

– 源代码下载 :

## 编译源代码

### 进入opencv源代码目录,在该目录中新建二个名为release的文书夹。

    “`

    cd ~/opencv/opencv-2.4.9

    mkdir release

    cd release

    “`

   
使用cmake工具在该公文夹中生成makefile文件,钦赐opencv的装置目录为/usr/local,opencv的源代码位于上一层目录。

    “`

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

    “`

### 假若cmake阶段一贯停在下载IPPICV那里,则按Ctrl C撤消

    手动下载ippicv_2017u3_lnx_intel64_general_20170822.tgz

   

###
然后进入~/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

    “`

### 然后再度运维编写翻译命令和安装命令:

    “`

    cd ~/Downloads/opencv3.3.1/build

    sudo cmake -D CMAKE_BUILD_TYPE=DEBUG -D
CMAKE_INSTALL_PREFIX=/usr/local ..

  sudo make

    sudo make install

    “`

1.设置 opencv 所需依赖包

借使前边还要遗漏的,出错再补上

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get -y install libopencv-dev build-essential cmake git
libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22
libdc1394-22-dev libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev
libavcodec-dev libavformat-dev libswscale-dev libxine2-dev
libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev
libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev
libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev
x264v4l-utils unzip

先是次尝试,太天真

2、下载opencv-2.4.10.zip,解压

2.下载 opencv3.2.0

此处须求下载 opencv 和 opencv_contrib (后者会在 cmake 配置的时候利用),
那是因为 opencv3以往 SIFT 和 SU昂科拉F 之类的性质被移到了 contrib
中,执行上边两条指令下载 OpenCV3.2.0

$ wget
https://github.com/opencv/opencv/archive/3.2.0.zip
$ wget
https://github.com/opencv/opencv\_contrib/archive/3.2.0.zip

(3.2.0.zip就是opencv-3.2.0.zip)
(3.2.0.zip.1就是opencv_contrib.zip)

一,更新ubuntu软件源

sudo apt-get update

3、编译opencv

3.解压下载的三个文件

$ unzip opencv-3.2.0.zip -d ~/opencv
$ unzip opencv_contrib-3.2.0.zip -d ~/opencv

二,opencv安装

sudo apt-get install libcv-dev

ps:删除配置文件

cd /var/cache/apt/archives
sudo apt-get clean

cd /home/opencv-2.4.10

4.创办并进入 build 目录,执行 cmake 生成 makefile 文件

$ cd ~/opencv/opencv-3.2.0
$ mkdir build
$ cd build/
$ sudo cmake -D CMAKE_BUILD_TYPE=Release -D
CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH= ..

注意cmake的参数不要出错

然后尝试

import cv2

到家的百般(
————————-分割——————————–

mkdir build

问题一:

下载包的时候链接超时

CMake Error at 3rdparty/ippicv/downloader.cmake:77 (message):
  ICV: Failed to download ICV package: ippicv_linux_20151201.tgz.
  Status=28;"Timeout was reached"

手动下载
ippicv_linux_20151201.tgz(https://raw.githubusercontent.com/Itseez/opencv\_3rdparty/81a676001ca8075ada498583e4166079e5744668/ippicv/ippicv\_linux\_20151201.tgz)到opencv-3.2.0/3rdparty/ippicv/downloads/目录下再cmake

$ sudo cp ~/software/opencv/ippicv_linux_20151201.tgz
~/opencv/opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/

其次次尝试

cd build/

问题二:

-- No package 'gtk+-3.0' found

$ sudo apt-get install libgtk-3-dev

1.opencv的有关正视

sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev
libavformat-dev cmake libswscale-dev libjasper-dev

下载
opencv3.2)

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

问题三:

--   No package 'gstreamer-base-1.0' found

--   No package 'gstreamer-video-1.0' found

--   No package 'gstreamer-app-1.0' found

--   No package 'gstreamer-riff-1.0' found

--   No package 'gstreamer-pbutils-1.0' found

sudo apt-get -y install libgstreamer-plugins-base1.0-dev
sudo apt-get -y install libgstreamer1.0-dev

2.编写翻译安装

打开终端,进入下载目录,并解压进入目录:

cd /home/yewii/下载
unzip opencv-3.3.0.zip
cd opencv-3.3.0

四 、结束后输入sudo make

问题四:

--   No package 'libavresample' found

--   No package 'libgphoto2' found

$ sudo apt-get -y install libavresample-dev
$ sudo apt-get -y install libgphoto2-dev

3.然后

cmake .

报错
CMake Error at CMakeLists.txt:11 (message): FATAL: In-source builds are not allowed. You should create separate directory for build files. -- Configuring incomplete, errors occurred!

接下来从sourceforge手动下载文件ippicv_windows_20141027.zip
下载文件后,将内容解压缩到opencv-3.3.0-阿尔法文件夹中的ippicv文件夹。
继续,。。。。。报错:
Checking for module 'gtk+-3.0' Checking:未找到命令

呵呵,又失败
去官网看Download
GStreamer

Download GStreamer

In general, you should find packages that were specifically made for your distribution. Do not compile from source yourself unless you are certain you have to or want to. Do not compile from Git unless you really need some specific feature that is not released yet, or want to help out developing GStreamer.

Linux Most, if not all, Linux distributions provide packages of GStreamer. You should find these in your distribution's package repository. Note that some distributions split the GStreamer plugins up further than the upstream sources. Additionally, some distributions do not include the gst-plugins-bad, gst-plugins-ugly, and gst-libav packages in their main repository, for legal reasons.

ubuntu 间接通过apt-get 安装,可是找不到,唯有去Sources
download。然后下载编写翻译一样特别!

————————-分割——————————–

⑤ 、然后在输入sudo make install

问题五:

-- Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
-- Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
-- Could NOT find Atlas (missing:  Atlas_CBLAS_INCLUDE_DIR Atlas_CLAPACK_INCLUDE_DIR Atlas_CBLAS_LIBRARY Atlas_BLAS_LIBRARY Atlas_LAPACK_LIBRARY) 
-- Could NOT find Doxygen (missing:  DOXYGEN_EXECUTABLE) 
-- Could NOT find JNI (missing:  JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) 
-- Could NOT find Matlab (missing:  MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN) 
-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file

$ sudo apt-get install libopenblas-dev

第N次尝试,真的,快到头的感到

觉得是opencv包和原先的有争辨,就悟出搭建2个沙盒。

前注:安装OpenCv
3.1的进程中要下载ippicv_linux_二零一五1201,由于网络的原因,这么些文件平时会下载战败,作者就遇到了,前面会讲到。

⑥ 、那样就编写翻译完结了,你能够在usr/local/lib下看看编写翻译好的opencv函数库

问题六:

-- Could NOT find Doxygen (missing:  DOXYGEN_EXECUTABLE) 

$ sudo apt-get install doxygen

一,老规矩,种种库和包文件更新和装置

$ sudo apt-get update
$ sudo apt-get upgrade

设置cmake,用来布局opencv build

$ sudo apt-get install build-essential cmake pkg-config
$ sudo apt-get install libjpeg8-dev libtiff5-dev libjasper-dev
libpng12-dev

从录制流和照相机中拿走文件

$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev
libv4l-dev
$ sudo apt-get install libxvidcore-dev libx264-dev

opencv GUI操作处理的模块名为highgui,而以此模块正视于GTK库

$ sudo apt-get install libgtk-3-dev

设置在opencv中用来优化函数的库

sudo apt-get install libatlas-base-dev gfortran

安装完python3.5的头文件和库

sudo apt-get install python3.5-dev

问题七:

-- Could NOT find JNI (missing:  JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) 

a.下载jdk-8u151-linux-x64.tar.gz到download目录
http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk8-downloads-2133151-zhs.html

b.安装jdk

$ cd download/
$ sudo mkdir /usr/local/java
$ sudo tar zxvf jdk-8u151-linux-x64.tar.gz -C /usr/local/java
$ sudo ln -s /usr/local/java/jdk1.8.0_151/ /usr/local/java/latest

c. 添加环境变量:

$ sudo vim /etc/profile

参预如下内容:

>export JAVA_HOME=/usr/local/java/latest
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

执行

$ source /etc/profile

展开立异。

尚无报错的情景下,cmake成功后会出现

-- Configuring done
-- Generating done
-- Build files have been written to: /home/fc/opencv/opencv-
3.2.0/build

二,下载文件,解压文件并跻身

下载链接opencv

unzip opencv.zip

下载opencv_contrib

unzip opencv_contrib.zip

5. make

cmake成功,之后方可在 build
文件下进行编写翻译指令,待编写翻译成功后即可举行安装指令。

$ sudo make -j4

出错:
/opencv/opencv-3.2.0/build/opencv_lapack.h:2:45: fatal error:
LAPACKE_H_PATH-NOTFOUND/lapacke.h: 没有十二分文件或目录
杀鸡取蛋办法:

$ sudo apt-get install liblapacke-dev checkinstall

make时间有点长,差不离八个小时了。

三,安装python环境

cd ~
wget
https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py

使用virtualenv 和 virtualenvwrapper

sudo pip install virtualenv virtualenvwrapper
sudo rm -rf ~/get-pip.py ~/.cache/pip

设置完virtualenv 和 virtualenvwrapper后,大家要求更新我们的~/.bashrc

virtualenv and virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh

重新加载变化

source ~/.bashrc

创办你的Python虚拟环境

mkvirtualenv cv -p python3

现在检察是否进入”cv”,假使进入,终端前会有(cv)
比方没有

workon cv

在虚拟环境中设置NumPy

pip install numpy

6.install

$ sudo make install

四,配置和编写翻译opencv

只顾:在大家开首前,再一次确认你是在cv的虚拟环境中
接下去我们应用CMake来安装和安排大家的build:

cd ~/opencv-3.1.0/
美高梅手机版4858,mkdir build
cd build

预编译cmake

cmake -D CMAKE_BUILD_TYPE=RELEASE
-D CMAKE_INSTALL_PREFIX=/usr/local
-D INSTALL_PYTHON_EXAMPLES=ON
-D INSTALL_C_EXAMPLES=OFF
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.1.0/modules
-D PYTHON_EXECUTABLE=~/.virtualenvs/cv/bin/python
-D BUILD_EXAMPLES=ON ..

接下来下载ippicv_linux_贰零壹陆1201并发难题,化解:

1.下载ippicv_linux_20151201
2.进入opencv目录

mkdir -p $ipp_dir &&
cp $ipp_file $ipp_dir

创建ippicv_linux_20151201的目录,带MD5.

ipp_file=../ippicv_linux_20151201.tgz &&
ipp_hash=$(md5sum $ipp_file | cut -d” ” -f1) &&
ipp_dir=3rdparty/ippicv/downloads/linux-$ipp_hash &&

比方CMake命令退出前卫未出现谬误,继续编写翻译

make clean
make
sudo make install
sudo ldconfig

7.设置 python 接口重视

$sudo apt-get install python-opencv
sudo apt-get install python-numpy

五,完成opencv安装

在运作sudo make
install后,你的OpenCV+Python3的包扎应在/usr/local/lib/python3.5/site-packages/,再度表明这几个利用ls命令:

ls -l /usr/local/lib/python3.5/site-packages/

出现toatal ***就对着

8.测试 Python 的 OpenCV3.2.0 模块

$ python
Python 2.7.14 |Anaconda, Inc.| (default, Oct 16 2017, 17:29:19) 
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
ImportError: No module named cv2
>>> 

问题:No module named cv2
缘由在于 python2.7 找不到 cv2.so 文本

$ sudo cp ~/opencv/opencv-3.2.0/build/lib/cv2.so
~/anaconda2/lib/python2.7/site-packages/

再测试:

$ python
Python 2.7.14 |Anaconda, Inc.| (default, Oct 16 2017, 17:29:19) 
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.2.0'
>>> 

能呈现opencv的版本表明安装成功

六,测试

开辟1个新的极端,进入cv的虚拟环境

python

import cv2

没报错,哈哈哈哈,终于成了。

开门红,今晚吃鸡

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图
Copyright @ 2010-2019 美高梅手机版4858 版权所有