Project

General

Profile

BuildOpenCV » History » Version 1

Anonymous, 04/09/2023 08:44 AM
creating page

1 1
h1. Building OpenCV
2
3
h2. Prerequisites
4
5
# Install CUDA: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/
6
# Install cuDNN:
7
<pre>
8
$ sudo apt install libcudnn8 libcudnn8-dev
9
</pre>
10
# Install OpenCV prereqs:
11
<pre>
12
$ sudo apt install build-essential cmake git pkg-config libgtk-3-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev gfortran openexr libatlas-base-dev python3-dev python3-numpy libtbb2 libtbb-dev libdc1394-22-dev libopenexr-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libvtk7-dev libdc1394-dev
13
</pre>
14
15
h2. Build from source
16
17
# From a working directory clone the contrib repository:
18
<pre>
19
$ git clone https://github.com/opencv/opencv_contrib.git
20
</pre>
21
# "Download":https://github.com/opencv/opencv/releases/tag/4.7.0 OpenCV release (currently 4.7.0) to working directory and untar:
22
<pre>
23
$ wget https://github.com/opencv/opencv/archive/refs/tags/4.7.0.tar.gz
24
$ tar xf 4.7.0.tar.gz
25
</pre>
26
# Create build directory and enter it:
27
<pre>
28
$ mkdir biuld
29
$ cd build
30
</pre>
31
# Configure build (NOTE: this will set the install directory to @/opt/local@, change as needed):
32
<pre>
33
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/opt/local -DOPENCV_GENERATE_PKGCONFIG=ON -DOPENCV_EXTRA_MODULES_PATH=../..//opencv_contrib/modules -DBUILD_opencv_legacy=OFF -DWITH_CUDA=ON -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_opencv_apps=OFF ..
34
</pre>
35
# Build (this will take a while) then install:
36
<pre>
37
$ make -j32
38
$ sudo make install
39
</pre>
40
41
h2. Miscellaneous
42
43
* To use the OpenCV Python bindings you need to set the @PYTHONPATH@ to include the install directory under @/opt/local@:
44
<pre>
45
$ export PYTHONPATH="/opt/local/lib/python3.10/dist-packages"
46
</pre>