-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathOpenCV_Install
118 lines (97 loc) · 5.69 KB
/
OpenCV_Install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
sudo apt-add-repository universe
sudo apt-get update
install ros?
IMPORTANT
##Current install sequence
python
cuda
gstreamer
opencv-ccmake version
ros-indigo
opencv-cmake version
https://devtalk.nvidia.com/default/topic/952041/ros-install-on-jetson-tx1-e-unable-to-locate-package-ros-indigo-desktop-full-my-thoughts/?offset=1
install cuda
#install python
sudo apt-get install python-dev
sudo apt-get install python-numpy
#install gsteamer 1.0
sudo apt-get install gstreamer1.0-tools gstreamer1.0-alsa \
gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
gstreamer1.0-plugins-ugly gstreamer1.0-plugins-bad gstreamer1.0-libav -y
#install opencv
sudo apt-get install build-essential cmake pkg-config
# Some general development libraries
sudo apt-get install -y build-essential make cmake cmake-curses-gui g++
# libav video input/output development libraries
sudo apt-get install -y libavformat-dev libavutil-dev libswscale-dev
# Video4Linux camera development libraries
sudo apt-get install -y libv4l-dev
# Eigen3 math development libraries
sudo apt-get install -y libeigen3-dev
# OpenGL development libraries (to allow creating graphical windows)
sudo apt-get install -y libglew1.6-dev
# GTK development libraries (to allow creating graphical windows)
sudo apt-get install -y libgtk2.0-dev
# GUI CMAKE
sudo apt-get install cmake-curses-gui
cd ~
mkdir src
cd src
unzip ~/Downloads/opencv-3.1.0.zip
cd opencv-3.1.0
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=RELEASE -DWITH_CUDA=ON -DCUDA_ARCH_BIN="5.3" -DCUDA_ARCH_PTX="" -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DCUDA_FAST_MATH=ON -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_PYTHON_SUPPORT=ON -DWITH_V4L=ON -DWITH_OPENGL=ON -DWITH_GTK=ON -DWITH_GTK_2_X=ON -DINSTALL_PYTHON_EXAMPLES=ON -DINSTALL_C_EXAMPLES=OFF -DBUILD_SHARED_LIBS=ON -DWITH_GSTREAMER=ON -DWITH_CUFFT=ON -DWITH_VTK=ON ..
make -j4 install
##This copies shared object files to site packages
## this allows from import cv2 = 3.1.0
sudo cp ~/src/opencv-3.1.0/build/lib/* /usr/local/lib/python2.7/site-packages/
##test bind import cv2 to 3.1.0
python
import sys
sys.path.insert(1, '/usr/local/lib/python2.7/site-packages')
import cv2
cv2.__version__
'3.1.0'
##add to header of any opencv python file to use opencv 3.1 this overrides ros version of opencv
import sys
sys.path.insert(1, '/usr/local/lib/python2.7/site-packages')
import cv2
>>> cv2.__version__
'3.1.0'
##links library for c++
sudo gedit /etc/ld.so.conf.d/opencv.conf
## add line below to file and save
/usr/local/lib
sudo ldconfig
sudo gedit /etc/bash.bashrc
## add lines below at bottom of file and save
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
## how to run c++ files
g++ `pkg-config --cflags opencv` facedetect.cpp `pkg-config --libs opencv` -o facedetect
#name of file here #creates file
./facedetect --camera 1
#to run generate executable
g++ `pkg-config --cflags opencv` farneback_optical_flow.cpp `pkg-config --libs opencv` -o farneback_optical_flow
./farneback_optical_flow --camera 1
http://www.askaswiss.com/2016/01/how-to-install-opencv-3-1-python-ubuntu-14-04.html
https://devtalk.nvidia.com/default/topic/917386/jetson-tx1/usb-3-0-port-unstable-on-jetson-tx1-/post/4835793/#4835793
http://www.pyimagesearch.com/2015/07/20/install-opencv-3-0-and-python-3-4-on-ubuntu/
http://www.samontab.com/web/2012/06/installing-opencv-2-4-1-ubuntu-12-04-lts/
#ignore lib4vl throws errors
#cmake -DCMAKE_BUILD_TYPE=RELEASE -DWITH_CUDA=ON -DCUDA_ARCH_BIN="5.3" -DCUDA_ARCH_PTX="" -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DCUDA_FAST_MATH=ON -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_PYTHON_SUPPORT=ON -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -DWITH_V4L=ON -DWITH_OPENGL=ON -DWITH_VTK=ON -DWITH_GTK_2_X=ON -DINSTALL_PYTHON_EXAMPLES=ON -DINSTALL_C_EXAMPLES=OFF -DWITH_GSTREAMER=ON -DWITH_CUFFT=ON -DWITH_LIBV4L=ON ..
cmake -DCMAKE_BUILD_TYPE=RELEASE -DWITH_CUDA=ON -DCUDA_ARCH_BIN="5.3" -DCUDA_ARCH_PTX="" -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DCUDA_FAST_MATH=ON -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_PYTHON_SUPPORT=ON -DWITH_V4L=ON -DWITH_OPENGL=ON -DWITH_GTK_2_X=ON -DINSTALL_PYTHON_EXAMPLES=ON -DINSTALL_C_EXAMPLES=OFF -DBUILD_SHARED_LIBS=ON -DWITH_GSTREAMER=ON -DWITH_CUFFT=ON ..
make -j4 install
##important note i did run ccmake with a bunch of extra stuff related to cuda acceleration and there was a successful build. successful build log was destroyed sudo rm of the opencv binaries
##i then reran with the cmake command to try and fix the bindings for python. This was not the way to fix it (correct way was python.syspath)but it ran a successful build
##there might be overlap with the ccmake and cmake build in case I ever need to remake opencv with fresh install
cmake -DCMAKE_BUILD_TYPE=RELEASE -DWITH_CUDA=ON -DCUDA_ARCH_BIN="5.3" -DCUDA_ARCH_PTX="" -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DCUDA_FAST_MATH=ON -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_PYTHON_SUPPORT=ON -DWITH_V4L=ON -DWITH_GTK=ON -DWITH_GTK_2_X=ON -DINSTALL_PYTHON_EXAMPLES=ON -DINSTALL_C_EXAMPLES=OFF -DBUILD_SHARED_LIBS=ON -DWITH_GSTREAMER=ON -DWITH_CUFFT=ON ..
sudo apt-get install libvtk5-dev python-vtk
This works
cmake -DCMAKE_BUILD_TYPE=RELEASE -DWITH_CUDA=ON -DCUDA_ARCH_BIN="5.3" -DCUDA_ARCH_PTX="" -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DCUDA_FAST_MATH=ON -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_PYTHON_SUPPORT=ON -DWITH_V4L=ON -DWITH_VTK=ON -DWITH_GTK_2_X=ON -DINSTALL_PYTHON_EXAMPLES=ON -DINSTALL_C_EXAMPLES=OFF -DWITH_GSTREAMER=ON -DBUILD_SHARED_LIBS=OFF -DWITH_CUFFT=ON ..
## graphcuts not supported cuda 8.0
/src/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp
change
-if !defined(HAVE_CUDA) || defined (CUDA_DISABLED)
+if !defined(HAVE_CUDA) || defined (CUDA_DISABLED) || (CUDA_VERSION >=8000)