OS: Ubuntu 18.04 Focal Package: OpenCV 3.4.5


1. ๋ฏธ๋ฆฌ ์„ค์น˜๋œ OpenCV ๋ฒ„์ „ ์‚ญ์ œ

๋‘๋ฒˆ์งธ ๋ช…๋ น์–ด ์‹คํ–‰์‹œ ๊ด€๋ จ๋œ ๋‹ค๋ฅธ ํŒจํ‚ค์ง€๋„์˜ํ–ฅ์„ ๋ฐ›์„ ์ˆ˜ ์žˆ์Œ
i.e. nvidia graphic driver

$ sudo apt purge libopencv* python3-opencv
$ sudo apt autoremove -y


2. ๋ถ€๊ฐ€ ํŒจํ‚ค์ง€ ์„ค์น˜

๋ธ”๋กœ๊ทธ ์ฐธ์กฐ: https://wth-mongdol.tistory.com/m/223

# ๋นŒ๋“œ, ์†Œ์Šค ๊ด€๋ จ
$ sudo apt install -y build-essential cmake pkg-config git

# ์ด๋ฏธ์ง€ ๊ด€๋ จ
$ sudo apt install -y libjpeg-dev libtiff5-dev libpng-dev libjasper-dev

# ๋™์˜์ƒ ๋ฐ ์นด๋ฉ”๋ผ ๊ด€๋ จ 
$ sudo apt install -y libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxvidcore-dev libx264-dev libxine2-dev libv4l-dev v4l-utils libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev

# GUI, qt, ์ตœ์ ํ™”, python3 ๊ด€๋ จ
$ sudo apt install -y libgtk-3-dev libatlas-base-dev libeigen3-dev gfortran
$ sudo apt install -y python3-dev python3-numpy libtbb2 libtbb-dev


3. OpenCV 3.4.5 ์„ค์น˜

opencv-x.x.x: ๊ธฐ๋ณธ ์†Œ์Šค ์ฝ”๋“œ

opencv_contrib-x.x.x: ์ถ”๊ฐ€ ๊ธฐ๋Šฅ ์ฝ”๋“œ(Extra Module, ์•Œ๊ณ ๋ฆฌ์ฆ˜, ํ…Œ์ŠคํŠธ ์ค‘์ธ ์‹ ๊ธฐ๋Šฅ ํฌํ•จ)

$ wget -O opencv-3.4.5.zip https://github.com/opencv/opencv/archive/3.4.5.zip
$ wget -O opencv_contrib-3.4.5.zip https://github.com/opencv/opencv_contrib/archive/3.4.5.zip

์••์ถ• ํ’€๊ธฐ

$ unzip opencv-3.4.5.zip
$ unzip opencv_contrib-3.4.5.zip

๋นŒ๋“œ ์ค€๋น„

 $ cd opencv-3.4.5
 $ mkdir build
 $ cd build

๋นŒ๋“œ

$ cmake \ -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D WITH_TBB=OFF \ -D WITH_IPP=OFF \ -D WITH_1394=OFF \ -D BUILD_WITH_DEBUG_INFO=OFF \ -D BUILD_DOCS=OFF \ -D INSTALL_C_EXAMPLES=ON \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D BUILD_EXAMPLES=OFF \ -D BUILD_TESTS=OFF \ -D BUILD_PERF_TESTS=OFF \ -D WITH_QT=ON \ -D WITH_GTK=OFF \ -D WITH_OPENGL=ON \ -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.4.5/modules \ -D WITH_V4L=ON \ -D WITH_FFMPEG=ON \ -D WITH_XINE=ON \ -D BUILD_NEW_PYTHON_SUPPORT=ON \ -D OPENCV_GENERATE_PKGCONFIG=ON ../

make

# ์ฝ”์–ด ๊ฐœ์ˆ˜ ํ™•์ธ
$ nproc 
$ make -j16

# ์ด์ œ ์„ค์น˜๋ฅผ ํ•ด์ค๋‹ˆ๋‹ค. 
$ sudo make install 


3. ๋ฒ„์ „ ํ™•์ธ

$ pkg-config --modversion opencv

Leave a comment