2015年11月12日 星期四

How to Install OpenCV3.0 for Mint17 or Ubuntu15.10

如何在 Mint17 或 ubuntu15安裝 OpenCV3.0

Mint17:

1.install files
sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next
sudo apt-get update
sudo apt-get install libopencv-dev build-essential checkinstall cmake pkg-config yasm libtiff4-dev libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils ffmpeg 


2.downlods
cd ~/
mkdir OpenCV3_Install
cd OpenCV3_Install
sudo apt-get install git
git clone https://github.com/Itseez/opencv.git

3.make
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
make -j4
sudo make install

4.patch

open this file
sudo gedit /etc/ld.so.conf.d/opencv.conf
add
"/usr/local/lib"
and run "sudo ldconfig "

open this file
sudo gedit /etc/bash.bashrc
add
"PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig"
"export PKG_CONFIG_PA"

Finish


=====================================================================
unubtu15.10

# 安裝需要的套件
sudo apt-get install libopencv-dev build-essential checkinstall cmake pkg-config yasm libtiff5-dev libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils ffmpeg

# 下載/OpenCV
cd ~/
mkdir OpenCV3_Install
cd OpenCV3_Install
sudo apt-get install git
git clone https://github.com/Itseez/opencv.git

# 準備編譯
cd opencv
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..

# 開始編譯
make -j4
sudo make install




sudo apt-get install gedit
clear
echo "================================="
echo "Now Add to file"
echo "================================="
echo "/usr/local/lib"
echo "================================="
sudo gedit /etc/ld.so.conf.d/opencv.conf
sudo ldconfig
clear
echo "================================="
echo "Now Add to file"
echo "================================="
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig"
echo "export PKG_CONFIG_PATH"
echo "================================="
sudo gedit /etc/bash.bashrc
echo "OpenCV version is"
pkg-config --modversion opencv

=====================================================================
TestFile
# -*- coding: utf-8 -*-
import cv2
import numpy as np
#  畫布大小
img = np.zeros((720,1280,3), np.uint8)
# (位置),大小,(顏色)粗度
cv2.circle(img,(200,200), 100, (0,0,255), 2)
# (第一個座標)(第二個座標)(顏色),粗度
cv2.rectangle(img,(350,100),(550,300),(0,255,0),3)
# (第一個座標)(第二個座標)(顏色),粗度
cv2.line(img,(600,100),(800,300),(255,0,0),10)
pts = np.array([[10,5],[20,30],[70,20],[50,10]], np.int32)
pts = pts.reshape((-1,1,2))
cv2.polylines(img,[pts],True,(0,255,255))
font = cv2.FONT_HERSHEY_SIMPLEX
# (座標),大小,(顏色),粗度
cv2.putText(img,'Charlotte.HonG',(0,500), font, 5,(255,255,255),10,cv2.LINE_AA)
while(1):
    cv2.imshow('Dring',img)
    if cv2.waitKey(20) & 0xFF == 27:
        break
cv2.destroyAllWindows()

Press "Esc" Exit

沒有留言:

張貼留言