์์ฑ์ผ์ - 23.05.22
https://webnautes.tistory.com/1433
์๋์ process๋ ์์ ํฐ์คํ ๋ฆฌ๋ธ๋ก๊ทธ์์ ์งํํด๋ณด๊ณ ํ์๊ฐ ์์ฃผ ํ์ํ์ฌ ๊ฐ์ ธ์ ์์ฝํ์๋ค.
์ฌ์ค jupyter notebook๊ณผ ๊ฐ์ ํ๊ฒฝ์์๋
install opencv-python
install opencv-contrib-python ๋ง ํด์ค๋ ๋๋ค..
๊ธฐ์กด OpenCV ํ์ธ
pkg-config --modversion opencv
์ ์ ๋ ฅํ์ ๋, opencv์ ๋ฒ์ ์ด ์ถ๋ ฅ๋๋ค๋ฉด, opencv๊ฐ ๊ธฐ์ค์น ๋์ด์๋ ๊ฒ์ด๊ณ , ์๋์ ์ฌ์ง๊ณผ ๊ฐ์ด ๋จ๋ฉด opencv๊ฐ ์ค์น๋์ด์์ง ์์ ๊ฒ์ด๋ค.
opencv ์ญ์
sudo apt-get purge libopencv* python-opencv
sudo apt-get autoremove
libopencv*์ ์ ๋ ฅํ์ฌ ๋ชจ๋ ๋ฒ์ ์ opencv ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ purge๋ฅผ ํตํด ์ญ์ ํ๋ค.
์ค์น์ค๋น
ํจํค์ง ์ ๊ทธ๋ ์ด๋
sudo apt update
sudo apt upgrade
๋ฅผ ํตํด ๊ธฐ๋ณธ์ ์ธ ํจํค์ง๋ฅผ ์ ๊ทธ๋ ์ด๋ํ๋ค.
sudo apt-get install build-essential cmake
sudo apt-get install pkg-config
sudo apt-get install libjpeg-dev libtiff5-dev libpng-dev
sudo apt-get install ffmpeg libavcodec-dev libavformat-dev libswscale-dev libxvidcore-dev libx264-dev libxine2-dev
sudo apt-get install libv4l-dev v4l-utils
sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
sudo apt-get install libgtk-3-dev
sudo apt-get install mesa-utils libgl1-mesa-dri libgtkgl2.0-dev libgtkglext1-dev
sudo apt-get install libatlas-base-dev gfortran libeigen3-dev
sudo apt-get install python3-dev python3-numpy
์ด ๋ง์ ํจํค์ง๋ค์ ํ๋ฒ์ ๋ค์ด๋ฐ๊ธฐ ์ํด ์๋์ฒ๋ผ ์ค์ฌ๋ณด์๋ค.
sudo apt-get install build-essential cmake pkg-config libjpeg-dev libtiff5-dev libpng-dev ffmpeg libavcodec-dev libavformat-dev libswscale-dev libxvidcore-dev libx264-dev libxine2-dev libv4l-dev v4l-utils libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgtk-3-dev mesa-utils libgl1-mesa-dri libgtkgl2.0-dev libgtkglext1-dev libatlas-base-dev gfortran libeigen3-dev python3-dev python3-numpy -y
์ญ ๊ธ์ด๋ค๊ฐ ์ ๋ ฅํ๋ฉด ๋ชจ๋ ํ๋ฐฉ์ ๊น๋ฆฐ๋ค. ์ด๋ํ ํ์๊ฐ ์์ฃผ ํ์ํด์ ์ค์ฌ๋ณด์๋ค.
OpenCV ์ค์น
๋๋ ํ ๋ฆฌ๋ฅผ ์๋ก ๋ง๋ ํ ์๋์ process๋ฅผ ์งํํ๋ค.
wget -O opencv.zip https://github.com/opencv/opencv/archive/4.4.0.zip
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.4.0.zip
unzip opencv.zip
unzip opencv_contrib.zip
๊ทธ๋ฅ opencv์ contrib_opencv ๋๋ค ์ค์นํด์ค๋ค.
ํ์๋ arucomarker๋ฑ ํ์ฅ opencv๊ฐ ํ์ํ๊ธฐ ๋๋ฌธ์ด๋ค.
์ด์ , opencv-4.4.0์ build๋๋ ํ ๋ฆฌ๋ฅผ ๋ง๋ค์ด cmakeํ๋ค.
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_PACKAGE=OFF -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D WITH_QT=OFF -D WITH_GTK=ON -D WITH_OPENGL=ON -D BUILD_opencv_python3=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.4.0/modules -D WITH_V4L=ON -D WITH_FFMPEG=ON -D WITH_XINE=ON -D OPENCV_ENABLE_NONFREE=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D OPENCV_SKIP_PYTHON_LOADER=ON -D OPENCV_GENERATE_PKGCONFIG=ON ../
-- General configuration for OpenCV 4.4.0 =====================================
-- Version control: unknown
--
-- Extra modules:
-- Location (extra): /home/skh/opencv/opencv_contrib-4.4.0/modules
-- Version control (extra): unknown
--
-- Platform:
-- Timestamp: 2023-05-22T14:43:49Z
-- Host: Linux 5.15.0-72-generic x86_64
-- CMake: 3.16.3
-- CMake generator: Unix Makefiles
-- CMake build tool: /usr/bin/make
-- Configuration: RELEASE
--
-- CPU/HW features:
-- Baseline: SSE SSE2 SSE3
-- requested: SSE3
-- Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
-- requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
-- SSE4_1 (15 files): + SSSE3 SSE4_1
-- SSE4_2 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2
-- FP16 (0 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
-- AVX (4 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
-- AVX2 (29 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
-- AVX512_SKX (4 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
--
-- C/C++:
-- Built as dynamic libs?: YES
-- C++ standard: 11
-- C++ Compiler: /usr/bin/c++ (ver 9.4.0)
-- C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
-- C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
-- C Compiler: /usr/bin/cc
-- C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
-- C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
-- Linker flags (Release): -Wl,--gc-sections -Wl,--as-needed
-- Linker flags (Debug): -Wl,--gc-sections -Wl,--as-needed
-- ccache: NO
-- Precompiled headers: NO
-- Extra dependencies: dl m pthread rt
-- 3rdparty dependencies:
--
-- OpenCV modules:
-- To be built: alphamat aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
-- Disabled: world
-- Disabled by dependency: -
-- Unavailable: cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv hdf java js julia matlab ovis python2 sfm ts viz
-- Applications: apps
-- Documentation: NO
-- Non-free algorithms: YES
--
-- GUI:
-- GTK+: YES (ver 3.24.20)
-- GThread : YES (ver 2.64.6)
-- GtkGlExt: NO
-- OpenGL support: NO
-- VTK support: NO
--
-- Media I/O:
-- ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
-- JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
-- WEBP: build (ver encoder: 0x020f)
-- PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.37)
-- TIFF: /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.1.0)
-- JPEG 2000: build Jasper (ver 1.900.1)
-- OpenEXR: build (ver 2.3.0)
-- HDR: YES
-- SUNRASTER: YES
-- PXM: YES
-- PFM: YES
--
-- Video I/O:
-- FFMPEG: YES
-- avcodec: YES (58.54.100)
-- avformat: YES (58.29.100)
-- avutil: YES (56.31.100)
-- swscale: YES (5.5.100)
-- avresample: NO
-- GStreamer: YES (1.16.3)
-- v4l/v4l2: YES (linux/videodev2.h)
-- Xine: YES (ver 1.2.9)
--
-- Parallel framework: pthreads
--
-- Trace: YES (with Intel ITT)
--
-- Other third-party libraries:
-- Lapack: NO
-- Eigen: YES (ver 3.3.7)
-- Custom HAL: NO
-- Protobuf: build (3.5.1)
--
-- OpenCL: YES (no extra features)
-- Include path: /home/skh/opencv/opencv-4.4.0/3rdparty/include/opencl/1.2
-- Link libraries: Dynamic load
--
-- Python 3:
-- Interpreter: /usr/bin/python3 (ver 3.8.10)
-- Libraries: /usr/lib/x86_64-linux-gnu/libpython3.8.so (ver 3.8.10)
-- numpy: /usr/lib/python3/dist-packages/numpy/core/include (ver 1.17.4)
-- install path: lib/python3.8/dist-packages
--
-- Python (for build): /usr/bin/python3
--
-- Java:
-- ant: NO
-- JNI: NO
-- Java wrappers: NO
-- Java tests: NO
--
-- Install to: /usr/local
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: /home/skh/opencv/opencv-4.4.0/build
์ ๊ฐ์ด opencv ๊ด๋ จ ์ปดํ์ผ ์ค์ ๊ฒฐ๊ณผ๊ฐ ๋์จ๋ค.
์๋ ์ธ์ค
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: /home/skh/opencv/opencv-4.4.0/build
๋ถ๋ถ์ด ์ถ๋ ฅ๋์๋ค๋ฉด, ์ ์์ ์ผ๋ก ๋ ๊ฒ์ด๋ค.
์ด ๋, python3 ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํญ๋ชฉ์ด ๋ณด์ด์ง ์๋๊ฒฝ์ฐ๋, cmakeํ ๋, python3๊ด๋ จ ๊ฒฝ๋ก๋ค์ ์ง์ ์ค์ ํด์ฃผ์ด์ผ ํ๋ค.
python3 ์ดํ ๋ถํฐ์ ๊ฒฝ๋ก๊ฐ python3 ์ ๊ด๋ จ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค.
time make -j$(nproc)
์ด์ , make๋ช ๋ น์ ํตํด ์ปดํ์ผ์ ์์ํ๋ค. ์์ time์ ๋ถ์ฌ ์ปดํ์ผ ํ ์๋ฃ ์๊ฐ์ด ๋จ๋๋ก ํ๋ค.
๋๋ค.
sudo make install
์ด์ , ๊ฒฐ๊ณผ๋ฌผ์ ์ค์นํ๋ค.
'SW > ์์์ฒ๋ฆฌ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
YOLOv5) yolov5 ์ฌ์ฉํด๋ณด๊ธฐ(test) (jupyter notebook) (0) | 2023.08.12 |
---|---|
OpenCV) OpenCV๋ฐ ๋์งํธ ์์์ฒ๋ฆฌ ๊ธฐ์ด (0) | 2023.01.22 |