☞ 메인보드 : Jetson Nano Developer Kit
☞ 운영 체제 : Ubuntu 18.04 - JetPack 4.3
목차
① OpenCV 설치 준비
이 설치는 Jetson Nano 보드로 진행하였다. 이 보드는 OpenCV 3.3.1 버전을 내장하고 있으며 pkg-config 명령어로 확인할 수 있다. [pkg-config 디렉터리 내에 존재하는 .pc 파일이 있는 경우에만 pkg-config 명령어로 확인이 가능하다.]
CUDA는 https://ko.wikipedia.org/wiki/CUDA 이곳에 잘 설명되어 있다.
요약 : 병렬처리연산에 적합한 작업의 효율을 향상한다.
더 요약 : 동시에 다수의 연산을 처리할 수 있다.
더 더 요약 : 빠르다.
CUDA 빌드를 위해 OpenCV 4 버전 이상을 사용해야 하므로 기존 버전을 제거해주고, 새 버전을 깔아야 한다.
(만약, No package 'opencv' found라는 문구가 나온다면, 무시하고 진행해도 상관없음)
★ 2020.10.23 ★
젯슨 나노 이미지는 JetPack 4.4.1(이 글을 쓸 당시에는 4.3 버전)으로 업그레이드되면서 소프트웨어 업데이트를 마치고 나면 OPENCV 4.1 버전이 이미 설치되어서 나온다. CUDA가 빠져있어서 기존 버전을 제거하고 재설치했습니다.
☞ 구버전 제거하기
sudo apt purge libopencv*
sudo apt autoremove
apt purge 명령어로 라이브러리를 제거할 수 있다. 해당 라이브러리에 의존성 관여가 되어 있는 패키지는 더 이상 필요 없기 때문에 autoremove 명령어로 삭제한다.
pkg-config --modversion opencv
다시 확인하면 opencv 는 없는 패키지라고 나온다.
삭제하고 나서 저장소 업데이트와 업그레이드를 진행하자.
sudo apt update && sudo apt upgrade
☞ 빌드에 필요한 패키지 설치하기
※ 필수 도구 + GUI
sudo apt install cmake cmake-qt-gui build-essential git pkg-config
터미널 창에서도 cmake --prefix 명령어로 진행할 수 있지만, 무슨 패키지가 빌드되는지도 모르는 초보자이므로 cmake-qt-gui를 이용하여 진행할 것이다.
※ 이미지
sudo apt install libjpeg-dev libtiff5-dev libpng-dev
※ 비디오 코덱
sudo apt install libavcodec-dev libavformat-dev libswscale-dev libxvidcore-dev libx264-dev x264 libxine2-dev libv4l-dev v4l-utils libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
※ OPENGL + 최적화 도구
sudo apt install mesa-utils libgl1-mesa-dri libqt4-opengl-dev libatlas-base-dev gfortran libeigen3-dev libtbb2 libtbb-dev
<참고>
mesa, opengl : 2D/3D 그래픽
atlas, eigen3 : 선형대수
gfortran : GCC(GNU Compiler Collection)
tbb : C++ 전용 멀티 코어 프로세서
※ 파이썬 패키지 관리 도구
sudo apt install python2.7-dev python3-dev python-numpy python3-numpy python3-setuptools
② OpenCV 설치
☞ 파일 다운로드
github opencv 저장소에서 다운로드한다.
wget -O opencv 'https://github.com/opencv/opencv/archive/4.2.0.zip'
wget -O opencv_contrib 'https://github.com/opencv/opencv_contrib/archive/4.2.0.zip'
알파벳 대문자 -O [디렉터리명] : 디렉터리명을 지정할 때 사용하는 옵션이다.
unzip opencv
unzip opencv_contrib
압축 해제하면 아래처럼 디렉터리가 생성될 것이다.
압축해제를 완료하고, build 디렉터리를 생성한다.
mkdir -p ~/opencv-4.2.0/build
☞ 빌드
cmake-gui 실행
cmake-gui
처음 실행하면 전부 비어있다.
source code와 binaries의 디렉터리를 설정해주는데, 압축해제를 홈에 했기 때문에
◎ source code : CMakeLists.txt가 있는 최상위의 디렉터리 (OpenCV의 처음 디렉터리)
◎ binaries : 미리 만들어준 build 폴더
그리고 Configure 버튼을 누르면
Makefile을 사용할 것이기 때문에 그냥 Finish 버튼을 누르고 진행
Configure 작업이 완료되고 추가된 플래그를 보면 가끔 NOT FOUND라는 게 보이는데 애내들은 CMAKE 에러의 파릇파릇 새싹들이다! 없애주는 작업을 하거나 필요한 것은 버전 업데이트하자. 의존성 문제가 있는지 확인하고 추가로 설치해주어야 한다.
☞ 빌드 ON/OFF 설정
바보같이 마우스로 내려가며 찾지 말고 Search 칸에 입력하여 찾길
<blas>
WITH_OPENCLAMDBLAS = OFF
WITH_OPENCLAMDFFT=OFF
<cpu>
CPU_BASELINE=AVX
CPU_DISPATCH='공백'
<cuda>
CUDA_FAST_MATH : 연산이 빨라 빨라
WITH_CUDA = ON : CUDA 사용해야지
OPENCV_DNN_CUDA = ON : cuDNN
CUDA_ARCH_BIN=8.6 (그래픽카드에 따라 다름 참고 - https://en.wikipedia.org/wiki/CUDA)
<extra>
OPENCV_EXTRA_MODULES_PATH :../../opencv_contrib-4.2.0/modules
opencv_contrib 폴더의 moudles 디렉터리
<gtk>
WITH_GTK = ON
<gl>
WITH_OPENGL = ON
<jas>
BUILD_JASPER = ON : 음성인식
<math>
ENABLE_FAST_MATH = ON : 부동소수점 무시 -> 연산 속도 향상
<nonfree>
OPENCV_ENABLE_NONFREE = ON : SIFT, SURF 알고리즘을 사용할 수 있음
시각 데이터 분석을 위해 체크하는데, 시간이 좀 걸리는 거로 알고 있음
<pkg>
OPENCV_GENERATE_PKGCONFIG = ON : PKGCONFIG(opencv.pc)를 추가해주기 위해 체크
opencv 4 버전 이 후로는 default 값이 OFF로 바뀐 모양
체크하지 않아도 문제는 없을 듯한데(실제로 돌아가긴 함)
설치가 완료되어도 pkg-config --modversion 명령어에 없는 패키지로 나옴
<python>
OPENCV_PYTHON3_VERSION=ON
<qt>
WITH_QT = ON
<tbb>
BUILD_TBB = ON
WITH_TBB = ON : 멀티 스레드 라이브러리
<vtk>
WITH_VTK = OFF
<world>
BUILD_opencv_world = OFF :
시간이 매우 오래 걸리나 opencv의 모듈을 하나의 파일로 빌드할 수 있도록 하는 opencv 3 버전 이후의 편리한 도구라고 생각~
하지만 나는 OFF 하겠음,
이 녀석을 빌드하지 않았다가 프로젝트를 만들 때 힘들었다는 글을 본 적이 있는데, 다른 라이브러리 한 곳에 뭉치기 때문에 다른 라이브러리가 정상적으로 빌드되지 않았을 경우 에러 메시지에 항상 떠 있다. 차라리 프로젝트에서 삽질을 하겠다...
취향으로 ON 또는 OFF 체크
BUILD_opencv_world=ON
시간이 오래걸려도 하자. 왠만한 에러는 여기서 다 해결할 수 있다. 왜냐면 프로젝트 전에 일찍 에러가 나기 때문이다.... 무조건 먼저하자. 그리고 나중에 프로젝트를 만들 때 world 라이브러리로 묶여 있는편이 쉽다. 꼭하자.
나는 test, exam는 전부 OFF로 했다.
분명 opencv를 3억 번 설치한 거 같은데 예제 파일을 실행해본 건처음 opencv를 접하고 면상 인식 예제를 한 번 실행한 것 이외에는 없다.
쓰는 언어에 따라서 체크하고 싶은 사람은 해도 상관없지만, 나는 절대로 안 쓸 거 같아서 빌드 시간을 줄이고자 체크를 지웠다.
<test>
BUILD_PERF_TESTS = OFF
BUILD_TESTS = OFF
BUILD_opencv_python_tests = OFF
INSTALL_TESTS = OFF
<exam>
BUILD_EXAMPLES = OFF
INSTALL_C_EXAMPLES = OFF
INSTALL_PYTHON_EXAMPLES =OFF
나머지는 알아서 체크되어 있는 것 같다. 다시 configure 해주면 또 결과가 다를 것이다.
☞ 사랑스러운 에러 발생
새 패키지를 설치하고 configure 버튼을 누르면 새 플래그들이 생긴다.
WITH_TESSERACT = OFF: 문자 인식 알고리즘을 사용하고 싶으면 ON으로 하고 패키지를 설치하기 바란다.
만약 패키지가 없거나 에러를 발견하면 당황하지 말고
※ No package 'libavresample' found
sudo apt install -y libavresample-dev
libavresample 패키지가 없음 -> 설치
※ Could NOT find Atlas (missing: Atlas_CLAPACK_INCLUDE_DIR)
sudo apt install -y liblapacke-dev
atlas clapack을 발견하지 못함 -> 설치
※ xfeatures2d/vgg 다운로드 30만 년 진행
vgg_generated, boostdesc_bgm 등 다운로드에 시간이 매우 오래 걸리면 에러 메시지가 나오는데 해당 빌드를 체크 해제 하자.(BUILD_opencv_xfeatures2d = OFF)
※ QT5 DIR NOT-FOUND
QT5 DIR NOT-FOUND
sudo apt install qt5-default
욕심이 많아 여러 가지를 체크해서 시간이 매우 오래 걸렸다...
전체 코드를 보려면 아래의 더보기를 클릭하세요.
Detected processor: aarch64
Looking for ccache - not found
Found ZLIB: /usr/lib/aarch64-linux-gnu/libz.so (found suitable version "1.2.11", minimum required is "1.2.3")
Found ZLIB: /usr/lib/aarch64-linux-gnu/libz.so (found version "1.2.11")
CUDA detected: 10.0
CUDA NVCC target flags: -gencode;arch=compute_53,code=sm_53;-D_FORCE_INLINES
LAPACK(Atlas): LAPACK_LIBRARIES: /usr/lib/aarch64-linux-gnu/liblapack.so;/usr/lib/aarch64-linux-gnu/libcblas.so;/usr/lib/aarch64-linux-gnu/libatlas.so
LAPACK(Atlas): Support is enabled.
Found apache ant: /usr/bin/ant (1.10.5)
OpenCV Python: during development append to PYTHONPATH: /home/yasun95/opencv-4.2.0/build/python_loader
Caffe: NO
Protobuf: NO
Glog: NO
Checking for module 'freetype2'
No package 'freetype2' found
freetype2: NO
harfbuzz: YES (ver 1.7.2)
Could NOT find HDF5 (missing: HDF5_LIBRARIES HDF5_INCLUDE_DIRS) (found version "")
Module opencv_ovis disabled because OGRE3D was not found
No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
Failed to find installed gflags CMake configuration, searching for gflags build directories exported with CMake.
Failed to find gflags - Failed to find an installed/exported CMake configuration for gflags, will perform search for installed gflags components.
Failed to find gflags - Could not find gflags include directory, set GFLAGS_INCLUDE_DIR to directory containing gflags/gflags.h
Failed to find glog - Could not find glog include directory, set GLOG_INCLUDE_DIR to directory containing glog/logging.h
Module opencv_sfm disabled because the following dependencies are not found: Glog/Gflags
Excluding from source files list: modules/imgproc/src/corner.avx.cpp
Excluding from source files list: modules/imgproc/src/imgwarp.avx2.cpp
Excluding from source files list: modules/imgproc/src/imgwarp.sse4_1.cpp
Excluding from source files list: modules/imgproc/src/resize.avx2.cpp
Excluding from source files list: modules/imgproc/src/resize.sse4_1.cpp
Excluding from source files list: modules/imgproc/src/sumpixels.avx512_skx.cpp
Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': /home/yasun95/opencv-4.2.0/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx.cpp
Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx2.cpp
Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx512_skx.cpp
Excluding from source files list: modules/features2d/src/fast.avx2.cpp
General configuration for OpenCV 4.2.0 =====================================
Version control: unknown
Platform:
Timestamp: 2020-01-22T11:46:50Z
Host: Linux 4.9.140-tegra aarch64
CMake: 3.10.2
CMake generator: Unix Makefiles
CMake build tool: /usr/bin/make
Configuration: Release
CPU/HW features:
Baseline: NEON FP16
required: NEON
disabled: VFPV3
C/C++:
Built as dynamic libs?: YES
C++ Compiler: /usr/bin/c++ (ver 7.4.0)
C++ flags (Release): -fsigned-char -ffast-math -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 -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
C++ flags (Debug): -fsigned-char -ffast-math -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 -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
C Compiler: /usr/bin/cc
C flags (Release): -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -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 -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
C flags (Debug): -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -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 -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release): -Wl,--gc-sections
Linker flags (Debug): -Wl,--gc-sections
ccache: NO
Precompiled headers: NO
Extra dependencies: m pthread /usr/lib/aarch64-linux-gnu/libGL.so /usr/lib/aarch64-linux-gnu/libGLU.so cudart_static dl rt nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cudnn cufft -L/usr/local/cuda/lib64 -L/usr/lib/aarch64-linux-gnu
3rdparty dependencies:
OpenCV modules:
To be built: aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy hfs highgui img_hash imgcodecs imgproc java line_descriptor ml objdetect optflow phase_unwrapping photo plot python2 python3 quality reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab ximgproc xobjdetect xphoto
Disabled: gapi python_tests world xfeatures2d
Disabled by dependency: -
Unavailable: cnn_3dobj freetype hdf js matlab ovis sfm viz
Applications: -
Documentation: NO
Non-free algorithms: YES
GUI:
QT: YES (ver 5.9.5)
QT OpenGL support: YES (Qt5::OpenGL 5.9.5)
OpenGL support: YES (/usr/lib/aarch64-linux-gnu/libGL.so /usr/lib/aarch64-linux-gnu/libGLU.so)
Media I/O:
ZLib: /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.11)
JPEG: /usr/lib/aarch64-linux-gnu/libjpeg.so (ver 80)
WEBP: build (ver encoder: 0x020e)
PNG: /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.6.34)
TIFF: /usr/lib/aarch64-linux-gnu/libtiff.so (ver 42 / 4.0.9)
JPEG 2000: build (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 (57.107.100)
avformat: YES (57.83.100)
avutil: YES (55.78.100)
swscale: YES (4.8.100)
avresample: YES (3.7.0)
GStreamer: YES (1.14.5)
v4l/v4l2: YES (linux/videodev2.h)
Parallel framework: TBB (ver 2020.0 interface 11100)
Trace: YES (with Intel ITT)
Other third-party libraries:
Lapack: YES (/usr/lib/aarch64-linux-gnu/liblapack.so /usr/lib/aarch64-linux-gnu/libcblas.so /usr/lib/aarch64-linux-gnu/libatlas.so)
Eigen: YES (ver 3.3.4)
Custom HAL: YES (carotene (ver 0.0.1))
Protobuf: build (3.5.1)
NVIDIA CUDA: YES (ver 10.0, CUFFT CUBLAS FAST_MATH)
NVIDIA GPU arch: 53
NVIDIA PTX archs:
cuDNN: YES (ver 7.5.0)
OpenCL: YES (no extra features)
Include path: /home/yasun95/opencv-4.2.0/3rdparty/include/opencl/1.2
Link libraries: Dynamic load
Python 2:
Interpreter: /usr/bin/python2.7 (ver 2.7.17)
Libraries: /usr/lib/aarch64-linux-gnu/libpython2.7.so (ver 2.7.17)
numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.13.3)
install path: lib/python2.7/dist-packages/cv2/python-2.7
Python 3:
Interpreter: /usr/bin/python3 (ver 3.6.9)
Libraries: /usr/lib/aarch64-linux-gnu/libpython3.6m.so (ver 3.6.9)
numpy: /usr/lib/python3/dist-packages/numpy/core/include (ver 1.13.3)
install path: lib/python3.6/dist-packages/cv2/python-3.6
Python (for build): /usr/bin/python2.7
Java:
ant: /usr/bin/ant (ver 1.10.5)
JNI: /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include/linux /usr/lib/jvm/default-java/include
Java wrappers: YES
Java tests: NO
Install to: /usr/local
-----------------------------------------------------------------
Configuring done
Detected processor: aarch64
Looking for ccache - not found
Found ZLIB: /usr/lib/aarch64-linux-gnu/libz.so (found suitable version "1.2.11", minimum required is "1.2.3")
Found ZLIB: /usr/lib/aarch64-linux-gnu/libz.so (found version "1.2.11")
CUDA detected: 10.0
CUDA NVCC target flags: -gencode;arch=compute_53,code=sm_53;-D_FORCE_INLINES
LAPACK(Atlas): LAPACK_LIBRARIES: /usr/lib/aarch64-linux-gnu/liblapack.so;/usr/lib/aarch64-linux-gnu/libcblas.so;/usr/lib/aarch64-linux-gnu/libatlas.so
LAPACK(Atlas): Support is enabled.
Found apache ant: /usr/bin/ant (1.10.5)
OpenCV Python: during development append to PYTHONPATH: /home/yasun95/opencv-4.2.0/build/python_loader
Caffe: NO
Protobuf: NO
Glog: NO
Checking for module 'freetype2'
No package 'freetype2' found
freetype2: NO
harfbuzz: YES (ver 1.7.2)
Could NOT find HDF5 (missing: HDF5_LIBRARIES HDF5_INCLUDE_DIRS) (found version "")
Module opencv_ovis disabled because OGRE3D was not found
No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
Failed to find installed gflags CMake configuration, searching for gflags build directories exported with CMake.
Failed to find gflags - Failed to find an installed/exported CMake configuration for gflags, will perform search for installed gflags components.
Failed to find gflags - Could not find gflags include directory, set GFLAGS_INCLUDE_DIR to directory containing gflags/gflags.h
Failed to find glog - Could not find glog include directory, set GLOG_INCLUDE_DIR to directory containing glog/logging.h
Module opencv_sfm disabled because the following dependencies are not found: Glog/Gflags
Excluding from source files list: modules/imgproc/src/corner.avx.cpp
Excluding from source files list: modules/imgproc/src/imgwarp.avx2.cpp
Excluding from source files list: modules/imgproc/src/imgwarp.sse4_1.cpp
Excluding from source files list: modules/imgproc/src/resize.avx2.cpp
Excluding from source files list: modules/imgproc/src/resize.sse4_1.cpp
Excluding from source files list: modules/imgproc/src/sumpixels.avx512_skx.cpp
Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': /home/yasun95/opencv-4.2.0/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx.cpp
Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx2.cpp
Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx512_skx.cpp
Excluding from source files list: modules/features2d/src/fast.avx2.cpp
General configuration for OpenCV 4.2.0 =====================================
Version control: unknown
Platform:
Timestamp: 2020-01-22T11:46:50Z
Host: Linux 4.9.140-tegra aarch64
CMake: 3.10.2
CMake generator: Unix Makefiles
CMake build tool: /usr/bin/make
Configuration: Release
CPU/HW features:
Baseline: NEON FP16
required: NEON
disabled: VFPV3
C/C++:
Built as dynamic libs?: YES
C++ Compiler: /usr/bin/c++ (ver 7.4.0)
C++ flags (Release): -fsigned-char -ffast-math -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 -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
C++ flags (Debug): -fsigned-char -ffast-math -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 -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
C Compiler: /usr/bin/cc
C flags (Release): -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -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 -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
C flags (Debug): -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -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 -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release): -Wl,--gc-sections
Linker flags (Debug): -Wl,--gc-sections
ccache: NO
Precompiled headers: NO
Extra dependencies: m pthread /usr/lib/aarch64-linux-gnu/libGL.so /usr/lib/aarch64-linux-gnu/libGLU.so cudart_static dl rt nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cudnn cufft -L/usr/local/cuda/lib64 -L/usr/lib/aarch64-linux-gnu
3rdparty dependencies:
OpenCV modules:
To be built: aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy hfs highgui img_hash imgcodecs imgproc java line_descriptor ml objdetect optflow phase_unwrapping photo plot python2 python3 quality reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab ximgproc xobjdetect xphoto
Disabled: gapi python_tests world xfeatures2d
Disabled by dependency: -
Unavailable: cnn_3dobj freetype hdf js matlab ovis sfm viz
Applications: -
Documentation: NO
Non-free algorithms: YES
GUI:
QT: YES (ver 5.9.5)
QT OpenGL support: YES (Qt5::OpenGL 5.9.5)
OpenGL support: YES (/usr/lib/aarch64-linux-gnu/libGL.so /usr/lib/aarch64-linux-gnu/libGLU.so)
Media I/O:
ZLib: /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.11)
JPEG: /usr/lib/aarch64-linux-gnu/libjpeg.so (ver 80)
WEBP: build (ver encoder: 0x020e)
PNG: /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.6.34)
TIFF: /usr/lib/aarch64-linux-gnu/libtiff.so (ver 42 / 4.0.9)
JPEG 2000: build (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 (57.107.100)
avformat: YES (57.83.100)
avutil: YES (55.78.100)
swscale: YES (4.8.100)
avresample: YES (3.7.0)
GStreamer: YES (1.14.5)
v4l/v4l2: YES (linux/videodev2.h)
Parallel framework: TBB (ver 2020.0 interface 11100)
Trace: YES (with Intel ITT)
Other third-party libraries:
Lapack: YES (/usr/lib/aarch64-linux-gnu/liblapack.so /usr/lib/aarch64-linux-gnu/libcblas.so /usr/lib/aarch64-linux-gnu/libatlas.so)
Eigen: YES (ver 3.3.4)
Custom HAL: YES (carotene (ver 0.0.1))
Protobuf: build (3.5.1)
NVIDIA CUDA: YES (ver 10.0, CUFFT CUBLAS FAST_MATH)
NVIDIA GPU arch: 53
NVIDIA PTX archs:
cuDNN: YES (ver 7.5.0)
OpenCL: YES (no extra features)
Include path: /home/yasun95/opencv-4.2.0/3rdparty/include/opencl/1.2
Link libraries: Dynamic load
Python 2:
Interpreter: /usr/bin/python2.7 (ver 2.7.17)
Libraries: /usr/lib/aarch64-linux-gnu/libpython2.7.so (ver 2.7.17)
numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.13.3)
install path: lib/python2.7/dist-packages/cv2/python-2.7
Python 3:
Interpreter: /usr/bin/python3 (ver 3.6.9)
Libraries: /usr/lib/aarch64-linux-gnu/libpython3.6m.so (ver 3.6.9)
numpy: /usr/lib/python3/dist-packages/numpy/core/include (ver 1.13.3)
install path: lib/python3.6/dist-packages/cv2/python-3.6
Python (for build): /usr/bin/python2.7
Java:
ant: /usr/bin/ant (ver 1.10.5)
JNI: /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include/linux /usr/lib/jvm/default-java/include
Java wrappers: YES
Java tests: NO
Install to: /usr/local
-----------------------------------------------------------------
Configuring done
③ Make + Make install
보드의 코어 수를 확인할 수 있다. [젯슨 나노의 경우 4개이다.]
nproc
make는 상당히 오래 걸리는 작업인데, pc가 갖고 있는 코어를 모두 가동하면 조금은 빠를 것이다.
그러나 코어를 모두 사용하는 데는 여유 분의 메모리가 필요하다. 그냥 해버리면 일정 확률로 freezing 현상이 일어나 강제 종료하고 처음부터 다시 해야 하는 불상사가 발생할 수도 있다.
free -h
스왑 영역의 여유 메모리를 늘려줘야 한다.
sudo fallocate -l 4096M /var/swap_temp
sudo chmod 600 /var/swap_temp
sudo mkswap /var/swap_temp
sudo swapon /var/swap_temp
여유 메모리를 4G 늘려주자
다시 확인하면,
cd ~/opencv-4.2.0/build
make -j1
이것저것 정말 많이 설치했기 때문에 상당히 무거운 작업이 됐다. 코어가 4개 있지만 동시에 돌리면 메모리가 못 버티니, 조금 오래 걸리더라도 1개나 2개만 사용하도록 하자. 혹시나 남는 FAN(선풍기...)가 있다면 젯슨 보드 방열판 위에 놓아 열을 식혀주기 바란다.
sudo make install
이리하면 설치가 완료된다.
이런 식으로 버전 확인을 하면 제대로 설치되었음을 알 수 있다!
다음 포스트에서는 설치한 opencv로 적당한 예제를 실행해볼 것이다--- 에러 발생은 댓글로
6. ROS + OPENCV (cv_bridge) 실시간 스트리밍
메인보드 : Jetson Nano Developer Kit 이미지 파일 버전 : JetPack 4.3 ROS 버전 : Ubuntu 18.04 LTS bionic > ROS Melodic 언어 : C++ <이전 포스트> ROS Melodic 언어 : C++ <이전 포스트> 4. 예제를 통한 ROS..
95mkr.tistory.com
+추가 내용 ROS1과 함께 사용하시는 분은 (Jetson에 설치되어있는 기본 OPENCV 버전은 지우셔도 괜찮지만), 4 버전 이상을 사용하실 수 없어요...... ROS1이 OPENCV 3.2.0 버전으로 하드 코딩되어 있기 때문에 ROS를 설치할 때 의존성 패키지로 함께 설치됩니다. ROS 사용하시는 분은 위 링크 참고하세요.
+2020.10.23 요새 젯슨 나노 이미지는 JetPack 4.4.1(이 글을 쓸 당시에는 4.3 버전)으로 업그레이드되면서 소프트웨어 업데이트를 마치고 나면 OPENCV 4.1 버전이 이미 설치되어서 나온다.
'IT > OPENCV' 카테고리의 다른 글
[OPENCV] 6. 이미지 프로세싱(2) - 샤프닝 & 가장자리 검출 (0) | 2021.05.08 |
---|---|
[OPENCV] 5. 색 공간 모델 HSV (3) | 2021.03.14 |
[OPENCV] 4. 이미지 프로세싱(1) - 블러링 (0) | 2020.12.13 |
[OPENCV] 3. OpenCV 실시간 영상 촬영 (6) | 2020.02.06 |
[OPENCV] 2. OpenCV 로 이미지 파일 출력하기 (4) | 2020.01.28 |