画像処理環境の構築③
今回は、OpenCV(4.5.1-pre)の環境構築を行います
画像処理環境の構築①
画像処理環境の構築②
1.環境構築前の準備
$ sudo apt update
$ sudo apt -yV upgrade
2.関連するファイルのインストール
$ sudo apt -yV install cmake
$ sudo apt -yV install git
$ sudo apt -yV install python3.9-dev
$ sudo apt -yV install build-essential
$ sudo apt -yV install libeigen3-dev
$ sudo apt -yV install libgtk-3-dev
$ sudo apt -yV install qt5-default
$ sudo apt -yV install libvtk7-qt-dev
$ sudo apt -yV install freeglut3-dev
$ sudo apt -yV install libtbb-dev
$ sudo apt -yV install libjpeg-dev
$ sudo apt -yV install libopenjp2-7-dev
$ sudo apt -yV install libpng++-dev
$ sudo apt -yV install libtiff-dev
$ sudo apt -yV install libopenexr-dev
$ sudo apt -yV install libwebp-dev
$ sudo apt -yV install libavresample-dev
$ sudo apt -yV install libhdf5-dev
3.OpenCVのファイル取得及びディレクトリの作成
$ cd /usr/local
$ sudo mkdir opencv4
$ cd /usr/local/opencv4
$ sudo git clone https://github.com/opencv/opencv.git
$ sudo git clone https://github.com/opencv/opencv_contrib.git
$ cd opencv
$ sudo mkdir build
$ cd build
4.CMAKEのオプション設定
$ sudo cmake \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_OPENCL=OFF \
-D WITH_CUDA=OFF \
-D BUILD_opencv_gpu=OFF \
-D BUILD_opencv_gpuarithm=OFF \
-D BUILD_opencv_gpubgsegm=OFF \
-D BUILD_opencv_gpucodec=OFF \
-D BUILD_opencv_gpufeatures2d=OFF \
-D BUILD_opencv_gpufilters=OFF \
-D BUILD_opencv_gpuimgproc=OFF \
-D BUILD_opencv_gpulegacy=OFF \
-D BUILD_opencv_gpuoptflow=OFF \
-D BUILD_opencv_gpustereo=OFF \
-D BUILD_opencv_gpuwarping=OFF \
-D BUILD_DOCS=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_EXAMPLES=OFF \
-D BUILD_opencv_python3=ON \
-D FORCE_VTK=ON \
-D WITH_TBB=ON \
-D WITH_V4L=ON \
-D WITH_OPENGL=ON \
-D WITH_CUBLAS=ON \
-D PYTHON3_EXECUTABLE=/usr/local/bin/python3.9 \
-D PYTHON3_INCLUDE_DIR=/usr/local/include/python3.9 \
-D PYTHON3_INCLUDE_DIR2=/usr/include/aarch64-linux-gnu/python3.9 \
-D PYTHON3_PACKAGES_PATH=/usr/local/lib/python3.9/site-packages \
-D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.9/site-packages/numpy/core/include \
-D PYTHON3_LIBRARIES=/usr/lib/aarch64-linux-gnu/libpython3.9.so \
-D WITH_FFMPEG=ON \
-S /usr/local/opencv4/opencv \
--
-- General configuration for OpenCV 4.5.1-pre =====================================
-- Version control: 4.5.0-276-gb023fcd264
--
-- Platform:
-- Timestamp: 2020-12-03T03:41:22Z
-- Host: Linux 5.8.0-1008-raspi aarch64
-- CMake: 3.16.3
-- CMake generator: Unix Makefiles
-- CMake build tool: /usr/bin/gmake
-- Configuration: RELEASE
--
-- CPU/HW features:
-- Baseline: NEON FP16
-- required: NEON
-- disabled: VFPV3
--
-- C/C++:
-- Built as dynamic libs?: YES
-- C++ standard: 11
-- C++ Compiler: /usr/bin/c++ (ver 10.2.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 -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -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 -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 -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 -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -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 -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -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: calib3d core dnn features2d flann gapi highgui imgcodecs imgproc ml objdetect photo python3 stitching video videoio
-- Disabled: world
-- Disabled by dependency: -
-- Unavailable: java js python2 ts
-- Applications: apps
-- Documentation: NO
-- Non-free algorithms: NO
--
-- GUI:
-- GTK+: YES (ver 3.24.23)
-- GThread : YES (ver 2.66.1)
-- GtkGlExt: NO
-- OpenGL support: NO
-- VTK support: YES (ver 7.1.1)
--
-- 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: /usr/lib/aarch64-linux-gnu/libwebp.so (ver encoder: 0x020e)
-- PNG: /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.6.37)
-- TIFF: /usr/lib/aarch64-linux-gnu/libtiff.so (ver 42 / 4.1.0)
-- JPEG 2000: OpenJPEG (ver 2.3.1)
-- OpenEXR: /usr/lib/aarch64-linux-gnu/libImath-2_5.so /usr/lib/aarch64-linux-gnu/libIlmImf-2_5.so /usr/lib/aarch64-linux-gnu/libIex-2_5.so /usr/lib/aarch64-linux-gnu/libHalf-2_5.so /usr/lib/aarch64-linux-gnu/libIlmThread-2_5.so (ver 2_5)
-- HDR: YES
-- SUNRASTER: YES
-- PXM: YES
-- PFM: YES
--
-- Video I/O:
-- DC1394: NO
-- FFMPEG: YES
-- avcodec: YES (58.91.100)
-- avformat: YES (58.45.100)
-- avutil: YES (56.51.100)
-- swscale: YES (5.7.100)
-- avresample: YES (4.0.0)
-- GStreamer: NO
-- v4l/v4l2: YES (linux/videodev2.h)
--
-- Parallel framework: TBB (ver 2020.3 interface 11103)
--
-- Trace: YES (with Intel ITT)
--
-- Other third-party libraries:
-- Lapack: NO
-- Eigen: YES (ver 3.3.7)
-- Custom HAL: YES (carotene (ver 0.0.1))
-- Protobuf: build (3.5.1)
--
-- Python 3:
-- Interpreter: /usr/local/bin/python3.9 (ver 3.9)
-- Libraries: /usr/lib/aarch64-linux-gnu/libpython3.9.so (ver 3.9.0)
-- numpy: /usr/local/lib/python3.9/site-packages/numpy/core/include (ver 1.19.4)
-- install path: /usr/local/lib/python3.9/site-packages/cv2/python-3.9
--
-- Python (for build): /usr/local/bin/python3.9
--
-- Java:
-- ant: NO
-- JNI: NO
-- Java wrappers: NO
-- Java tests: NO
--
-- Install to: /usr/local
-- -----------------------------------------------------------------
5.OpenCVのインストール
$ sudo make -j4
$ sudo make install
6.バージョンの確認
$ opencv_version
4.5.1-pre
$ python3 -c 'import cv2; print(cv2.__version__);'
4.5.1-pre
7.バッチファイル
8.次回予定
UbuntuでPicameraを認識させてVideo0を有効にする
カメラ画像をディスプレイ上に表示