HOME
  Security
   Software
    Hardware
  
FPGA
  CPU
   Android
    Raspberry Pi
  
nLite
  Xcode
   etc.
    ALL
  
English Translate 中文翻訳
LINK
BACK
 

[NEW] 2018/09/01

Raspberry Pi 3用に NEONと VFPV3を有効化して最適化版の OpenCVをビルドする方法 Raspberry Pi 3用に NEONと VFPV3を有効化して最適化版の OpenCVをビルドする方法

(ラズパイ3用に NEONと VFPV3を有効化した最適化版の OpenCVをビルドする方法)

Tags: [Raspberry Pi], [電子工作]





● Raspberry Pi 3用に最適化版の OpenCVをソースコードからビルドする方法

 画像処理ライブラリの定番の OpenCVを Raspberry Pi 3用に最適化版をビルドします。

 具体的には FAST_MATHと NEONと VFPV3を有効にしてビルドします。

 更に通常の libjpegライブラリと比べて 2~6倍速い libjpeg-turboライブラリを OpenCVに組み込みます。


● OpenCVの 4コアビルドはメモリを沢山使うので不要なサービス等を停止して使えるメインメモリを増やす


[NEW] 2018/08/14
Raspberry Piでメモリを馬鹿食いするアプリ用に不要なサービスを停止してフリーメモリを増やす方法
Raspberry Piでメモリを馬鹿食いするアプリ用に不要なサービスを停止してフリーメモリを増やす方法

  ラズパイでメモリを沢山使用するビルドやアプリ用に不要なサービス等を停止して使えるメインメモリを増やす


● Raspberry Pi 3用に NEONと VFPV3を有効化して最適化版の OpenCVをビルドする方法

 OpenCV - Open Source Computer Vision

 ここのビルド手順通りに行ないます。
Installation in Linux

Open Source Computer Vision Library

・ OpenCV 3.4.3
@alalek alalek released this Aug 29, 2018 · 120 commits to master since this release
https://github.com/opencv/opencv/archive/3.4.3.zip

Repository for OpenCV's extra modules

・ OpenCV contrib 3.4.3
@alalek alalek tagged this Aug 28, 2018 · 41 commits to master since this tag
https://github.com/opencv/opencv_contrib/archive/3.4.3.zip

 OpenCV 3.4.3
# お決まりの sudo apt-get updateで最新状態に更新する
sudo apt-get update

# Required Packages
# compiler
sudo apt-get -y install build-essential

# required
sudo apt-get -y install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

# optional
sudo apt-get -y install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
# libjpeg-devの指定だけでも libjpeg-dev libjpeg62-turbo-devが自動的にインストールされます。
# libtiff-devの指定だけでも libjpeg-dev libjpeg62-turbo-devが自動的にインストールされます。

# Getting OpenCV Source Code
cd
wget -O opencv_343.zip https://github.com/opencv/opencv/archive/3.4.3.zip
unzip opencv_343.zip

# Getting OpenCV Source Code
wget -O opencv_contrib_343.zip https://github.com/opencv/opencv_contrib/archive/3.4.3.zip
unzip opencv_contrib_343.zip
ls -l ~/opencv_contrib-3.4.3/modules

# Building OpenCV from Source Using CMake
cd
cd opencv-3.4.3
mkdir build
cd build

# Optimizing OpenCV on the Raspberry Pi ENABLE_NEON ENABLE_VFPV3
#    -D ENABLE_FAST_MATH=ON \
#    -D ENABLE_NEON=ON \
#    -D ENABLE_VFPV3=ON \
# cmake ..
cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.4.3/modules \
    -D ENABLE_FAST_MATH=ON \
    -D ENABLE_NEON=ON \
    -D ENABLE_VFPV3=ON \
    -D BUILD_TESTS=OFF \
    -D INSTALL_PYTHON_EXAMPLES=OFF \
    -D BUILD_EXAMPLES=OFF ..
# libjpeg-dev等のデフォルトの JPEGライブラリが無い場合は OpenCV内の libjpeg-turbo(ver 1.5.3-62)を使用します。
-- Could NOT find JPEG (missing:  JPEG_LIBRARY JPEG_INCLUDE_DIR)
-- libjpeg-turbo: VERSION = 1.5.3, BUILD = opencv-3.4.3-libjpeg-turbo

# make -j4で 4コアで OpenCVをビルドします
make -j4

# Raspberry Pi 3B
# real    128m22.768s
# user    294m47.041s
# sys     8m18.067s

# Raspberry Pi 3B+
# real    84m35.168s
# user    235m52.146s
# sys     6m47.118s

# ビルドした OpenCVバイナリをインストールします
sudo make install

# Update Lib info.
sudo ldconfig

# Python 2.7.13
python -V
python -c "import cv2; print(cv2.__version__);"
# 3.4.3

# Python 3.5.3
python3 -V
python3 -c "import cv2; print(cv2.__version__);"
# 3.4.3

pi@raspberrypi:~/opencv-3.4.3/build $ python -V
Python 2.7.13

pi@raspberrypi:~/opencv-3.4.3/build $ python -c "import cv2; print(cv2.__version__);"
3.4.3

pi@raspberrypi:~/opencv-3.4.3/build $ python3 -V
Python 3.5.3

pi@raspberrypi:~/opencv-3.4.3/build $ python3 -c "import cv2; print(cv2.__version__);"
3.4.3

# OpenCV Running tests
cd
# OpenCV extra repository
git clone https://github.com/opencv/opencv_extra.git

# execute tests from build directory
cd
cd opencv-3.4.3
export OPENCV_TEST_DATA_PATH=~/opencv_extra/testdata/
./bin/opencv_test_core

● cmakeのログ(抜粋)

sudo apt-get -y install libjpeg-dev
# libjpeg-dev (1:1.5.1-2)
 libjpeg.so (ver 62)

libjpeg62-turbo - libjpeg-turbo JPEG runtime library
libjpeg62-turbo-dev - Development files for the libjpeg-turbo JPEG library
libturbojpeg0 - TurboJPEG runtime library - SIMD optimized
libturbojpeg0-dev - Development files for the TurboJPEG library


● OpenCV cmake ..で最適化を何もしない時
cmake ..
...
--   CPU/HW features:
--     Baseline:
--       requested:                 DETECT
--       disabled:                  VFPV3 NEON
...
--     JPEG:                        libjpeg-turbo (ver 1.5.3-62)

● OpenCV 最適化を有りの時
cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.4.3/modules \
    -D ENABLE_FAST_MATH=ON \
    -D ENABLE_NEON=ON \
    -D ENABLE_VFPV3=ON \
    -D BUILD_TESTS=OFF \
    -D INSTALL_PYTHON_EXAMPLES=OFF \
    -D BUILD_EXAMPLES=OFF ..

...
--   Other third-party libraries:
--     Lapack:                      NO
--     Eigen:                       NO
--     Custom HAL:                  YES (carotene (ver 0.0.1))
--     Protobuf:                    build (3.5.1)
--
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/pi/opencv-3.4.3/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
--
--   Python 2:
--     Interpreter:                 /usr/bin/python2.7 (ver 2.7.13)
--     Libraries:                   /usr/lib/arm-linux-gnueabihf/libpython2.7.so (ver 2.7.13)
--     numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.12.1)
--     packages path:               lib/python2.7/dist-packages
--
--   Python 3:
--     Interpreter:                 /usr/bin/python3 (ver 3.5.3)
--     Libraries:                   /usr/lib/arm-linux-gnueabihf/libpython3.5m.so (ver 3.5.3)
--     numpy:                       /usr/lib/python3/dist-packages/numpy/core/include (ver 1.12.1)
--     packages path:               lib/python3.5/dist-packages
--
--   Python (for build):            /usr/bin/python2.7
--
--   Java:
--     ant:                         NO
--     JNI:                         NO
--     Java wrappers:               NO
--     Java tests:                  NO
--
--   Matlab:                        NO
--
--   Install to:                    /usr/local
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/opencv-3.4.3/build

● Raspberry Pi 3B+で cmake ..の時のビルド時間 62分
# Raspberry Pi 3B+
cmake ..
make -j4
のビルド時間

real    61m53.181s
user    214m30.838s
sys     5m27.486s


● opencv_test.py
import cv2
import time

print(cv2.__version__);
# 3.4.3

t1 = time.time();
for i in range(1000):
    # Load Jpeg image
    im = cv2.imread('lena.jpg')
t2 = time.time();
print("imread time seconds: {:.5}".format(t2 - t1));

● Raspberry Pi 3B+で最適化有無と libjpeg-turboでの OpenCVのベンチマーク

最適化
-D ENABLE_FAST_MATH=ON \
-D ENABLE_NEON=ON \
-D ENABLE_VFPV3=ON \

libjpeg
libjpeg.so (ver 62)
libjpeg-turbo
libjpeg-turbo (ver 1.5.3-62)
/opt/libjpeg-turbo/lib32/libjpeg.a (ver 62)

 ※ ビルドしているうちに混乱して訳が分からなくなったので参考程度に。
最適化有無
NEON VFP3 FAST-MATH
libjpeg実行時間(秒)
python3
ビルド時間(分)
無しlibjpeg-turbo ver 1.5.3-6225.07170分
無しlibjpeg-turbo ver 2.0.025.30470分
有りlibjpeg.so (ver 62)25.08385分
有りlibjpeg-turbo ver 1.5.3-6284分
有りlibjpeg-turbo ver 2.0.011.242110分

● Raspberry Pi 3B+で最適化無しの OpenCVのベンチマーク
wget https://github.com/opencv/opencv/raw/master/samples/data/lena.jpg

 OpenCV 最適化無し + libjpeg-turbo ver 1.5.3-62

pi@raspberrypi:~/opencv-3.4.3/build $ python opencv_test.py
3.4.3
imread time seconds: 25.055

pi@raspberrypi:~/opencv-3.4.3/build $ python3 opencv_test.py
3.4.3
imread time seconds: 25.071

● Raspberry Pi 3B+で libjpeg-turbo 2.0.0だけの OpenCVのベンチマーク
 OpenCV 最適化無し + libjpeg-turbo 2.0.0
 結論: libjpeg-turbo 1.5.3-62と比べた場合 libjpeg-turbo 2.0.0にしても速度的な恩恵は無い
# Raspberry Pi 3B+
cmake ..
make -j4
のビルド時間

real    69m20.725s
user    212m10.991s
sys     5m58.512s

pi@raspberrypi:~/opencv-3.4.3/build $ python opencv_test.py
3.4.3
imread time seconds: 25.219

pi@raspberrypi:~/opencv-3.4.3/build $ python3 opencv_test.py
3.4.3
imread time seconds: 25.304

● Raspberry Pi 3B+で最適化有りの OpenCVのベンチマーク
 OpenCV 最適化 + libjpeg-turbo 2.0.0
pi@raspberrypi:~/opencv-3.4.3/build $ python opencv_test.py
3.4.3
imread time seconds: 10.982
pi@raspberrypi:~/opencv-3.4.3/build $ python3 opencv_test.py
3.4.3
imread time seconds: 11.242


● ビルドした OpenCVの Python言語での動作確認

import cv2 as cv
print(cv.__version__)
# 3.4.3


● ビルドした OpenCVの Python言語での動作確認

 OpenCV libjpeg-turbo版で確認
 下記の手順で ビルドした OpenCVの Python言語での動作確認が出来ました。
 Python 2.7.13、Python 3.5.3の両方で動作確認済み。


[NEW] 2018/09/04
Raspberry Piで OpenCVを使って Python言語で JPEG画像ファイルを読み書きする方法
Raspberry Piで OpenCVを使って Python言語で JPEG画像ファイルを読み書きする方法

  ラズパイの OpenCVで Python言語を使って JPEG画像ファイルを読み書きする方法


● OpenCVの Jpeg画像の読み書きに libjpeg-turboを使う

 通常の libjpegライブラリと比べて 2~6倍速い libjpeg-turboライブラリを OpenCVに組み込みます。


Install OpenCV-Python in Ubuntu

libjpeg-turbo
 libjpeg-turbo is a JPEG image codec that uses SIMD instructions (MMX, SSE2, AVX2, NEON, AltiVec)
 libjpeg-turbo is generally 2-6x as fast as libjpeg

https://github.com/libjpeg-turbo/libjpeg-turbo

● Building libjpeg-turbo

● libjpeg-turbo 1.5.3の場合
# libjpeg-turbo 1.5.3
# @dcommander dcommander released this Dec 14, 2017
cd
wget -O libjpeg-turbo_153.zip https://github.com/libjpeg-turbo/libjpeg-turbo/archive/1.5.3.zip
unzip libjpeg-turbo_153.zip

cd
cd libjpeg-turbo-1.5.3
sudo apt-get -y install nasm
sudo apt-get -y install dh-autoreconf
autoreconf -fiv

mkdir build
cd build
../configure --prefix=/usr/libjpeg-turbo --mandir=/usr/share/man --with-jpeg8 --enable-static --docdir=/usr/share/doc/libjpeg-turbo-1.5.3

# 不要
# CC= gcc -fPIC
# nano Makefile

# Build libjpeg-turbo
make -j4

# make test

# Install libjpeg-turbo
sudo make install

pi@raspberrypi:~/libjpeg-turbo-1.5.3/build $ ls -l /usr/libjpeg-turbo/lib/libjpeg.a
-rw-r--r-- 1 root root 334920 Sep  3 02:30 /usr/libjpeg-turbo/lib/libjpeg.a

# OpenCV cmake add line
    -D WITH_JPEG=ON \
    -D BUILD_JPEG=OFF \
    -D JPEG_INCLUDE_DIR=/usr/libjpeg-turbo/include \
    -D JPEG_LIBRARY=/usr/libjpeg-turbo/lib/libjpeg.a \

# OpenCV cmake
cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D WITH_JPEG=ON \
    -D BUILD_JPEG=OFF \
    -D JPEG_INCLUDE_DIR=/usr/libjpeg-turbo/include \
    -D JPEG_LIBRARY=/usr/libjpeg-turbo/lib/libjpeg.a \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.4.3/modules \
    -D ENABLE_FAST_MATH=ON \
    -D ENABLE_NEON=ON \
    -D ENABLE_VFPV3=ON \
    -D BUILD_TESTS=OFF \
    -D INSTALL_PYTHON_EXAMPLES=OFF \
    -D BUILD_EXAMPLES=OFF ..

-- General configuration for OpenCV 3.4.3 =====================================
...
--   CPU/HW features:
--     Baseline:                    VFPV3 NEON
--       requested:                 DETECT
--       required:                  VFPV3 NEON
--
...
--     JPEG:                        /usr/libjpeg-turbo/lib/libjpeg.a (ver 80)

make -j4
sudo make install
sudo ldconfig

● libjpeg-turbo 2.0.0の場合
# libjpeg-turbo 2.0.0
# @dcommander dcommander released this Jul 27, 2018
cd
wget -O libjpeg-turbo_200.zip https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.0.0.zip
unzip libjpeg-turbo_200.zip

cd
cd libjpeg-turbo-2.0.0
mkdir build
cd build
cmake ..

# Build libjpeg-turbo
make -j4
# 3分でビルド完了

make test

# Install libjpeg-turbo
sudo make install

# /opt/libjpeg-turbo/include
# /opt/libjpeg-turbo/lib32
pi@raspberrypi:~/libjpeg-turbo-2.0.0/build $ ls -l /opt/libjpeg-turbo/lib32/libjpeg.a
-rw-r--r-- 1 root root 342026 Sep  3 06:27 /opt/libjpeg-turbo/lib32/libjpeg.a

# OpenCV cmake add line
    -D WITH_JPEG=ON \
    -D BUILD_JPEG=OFF \
    -D JPEG_INCLUDE_DIR=/opt/libjpeg-turbo/include \
    -D JPEG_LIBRARY=/opt/libjpeg-turbo/lib32/libjpeg.a \

# OpenCV cmake
cd
cd opencv-3.4.3
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D WITH_JPEG=ON \
    -D BUILD_JPEG=OFF \
    -D JPEG_INCLUDE_DIR=/opt/libjpeg-turbo/include \
    -D JPEG_LIBRARY=/opt/libjpeg-turbo/lib32/libjpeg.a \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.4.3/modules \
    -D ENABLE_FAST_MATH=ON \
    -D ENABLE_NEON=ON \
    -D ENABLE_VFPV3=ON \
    -D BUILD_TESTS=OFF \
    -D INSTALL_PYTHON_EXAMPLES=OFF \
    -D BUILD_EXAMPLES=OFF ..

-- General configuration for OpenCV 3.4.3 =====================================
...
--   CPU/HW features:
--     Baseline:                    VFPV3 NEON
--       requested:                 DETECT
--       required:                  VFPV3 NEON
--
...
--     JPEG:                        /opt/libjpeg-turbo/lib32/libjpeg.a (ver 62)
...
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/opencv-3.4.3/build

# OpenCV 3.4.3 4コアビルドで 117分で完了(Raspberry Pi 3B)
make -j4

sudo make install
sudo ldconfig

make -j4
...
[100%] Linking CXX executable ../../bin/opencv_perf_stitching
[100%] Built target opencv_perf_stitching
[100%] Linking CXX executable ../../bin/opencv_perf_optflow
[100%] Built target opencv_perf_optflow
[100%] Linking CXX shared module ../../lib/cv2.so
[100%] Built target opencv_python2
[100%] Linking CXX shared module ../../lib/python3/cv2.cpython-35m-arm-linux-gnueabihf.so
[100%] Built target opencv_python3

real    116m45.347s
user    290m18.940s
sys     7m44.790s

pi@raspberrypi:~/libjpeg-turbo-2.0.0/build $ cmake ..
-- The C compiler identification is GNU 6.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- CMAKE_BUILD_TYPE = Release
-- VERSION = 2.0.0, BUILD = 20180903
-- 32-bit build (arm)
-- CMAKE_INSTALL_PREFIX = /opt/libjpeg-turbo
-- CMAKE_INSTALL_BINDIR = bin (/opt/libjpeg-turbo/bin)
-- CMAKE_INSTALL_DATAROOTDIR =  (/opt/libjpeg-turbo)
-- CMAKE_INSTALL_DOCDIR = doc (/opt/libjpeg-turbo/doc)
-- CMAKE_INSTALL_INCLUDEDIR = include (/opt/libjpeg-turbo/include)
-- CMAKE_INSTALL_LIBDIR = lib32 (/opt/libjpeg-turbo/lib32)
-- CMAKE_INSTALL_MANDIR = man (/opt/libjpeg-turbo/man)
-- Shared libraries enabled (ENABLE_SHARED = 1)
-- Static libraries enabled (ENABLE_STATIC = 1)
-- 12-bit JPEG support disabled (WITH_12BIT = 0)
-- Arithmetic decoding support enabled (WITH_ARITH_DEC = 1)
-- Arithmetic encoding support enabled (WITH_ARITH_ENC = 1)
-- TurboJPEG API library enabled (WITH_TURBOJPEG = 1)
-- TurboJPEG Java wrapper disabled (WITH_JAVA = 0)
-- In-memory source/destination managers enabled (WITH_MEM_SRCDST = 1)
-- Emulating libjpeg API/ABI v6.2 (WITH_JPEG7 = 0, WITH_JPEG8 = 0)
-- libjpeg API shared library version = 62.3.0
-- Compiler flags =  -O3 -DNDEBUG
-- Linker flags =
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of size_t
-- Check size of size_t - done
-- Check size of unsigned long
-- Check size of unsigned long - done
-- Performing Test HAVE_BUILTIN_CTZL
-- Performing Test HAVE_BUILTIN_CTZL - Success
-- Looking for include file locale.h
-- Looking for include file locale.h - found
-- Looking for include file stdlib.h
-- Looking for include file stdlib.h - found
-- Looking for include file sys/types.h
-- Looking for include file sys/types.h - found
-- Looking for memset
-- Looking for memset - found
-- Looking for memcpy
-- Looking for memcpy - found
-- Check size of unsigned char
-- Check size of unsigned char - done
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Performing Test INCOMPLETE_TYPES
-- Performing Test INCOMPLETE_TYPES - Success
-- Compiler supports pointers to undefined structures.
-- Performing Test RIGHT_SHIFT_IS_UNSIGNED
-- Performing Test RIGHT_SHIFT_IS_UNSIGNED - Failed
-- Performing Test __CHAR_UNSIGNED__
-- Performing Test __CHAR_UNSIGNED__ - Success
-- Performing Test INLINE_WORKS
-- Performing Test INLINE_WORKS - Success
-- INLINE = __inline__ __attribute__((always_inline)) (FORCE_INLINE = 1)
-- Performing Test HAVE_VERSION_SCRIPT
-- Performing Test HAVE_VERSION_SCRIPT - Success
-- Linker supports GNU-style version scripts
-- CMAKE_EXECUTABLE_SUFFIX =
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- CMAKE_ASM_FLAGS =   -O3 -DNDEBUG
-- GAS is working properly
-- SIMD extensions: arm (WITH_SIMD = 1)
-- FLOATTEST = 32bit
-- RPM architecture = armv7l, DEB architecture = armhf
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/libjpeg-turbo-2.0.0/build

pi@raspberrypi:~/libjpeg-turbo-2.0.0/build $ cmake .. --help
Usage

  cmake [options] <path-to-source>
  cmake [options] <path-to-existing-build>

Specify a source directory to (re-)generate a build system for it in the
current working directory.  Specify an existing build directory to
re-generate its build system.

Options
  -C <initial-cache>           = Pre-load a script to populate the cache.
  -D <var>[:<type>]=<value>    = Create a cmake cache entry.
  -U <globbing_expr>           = Remove matching entries from CMake cache.
  -G <generator-name>          = Specify a build system generator.
  -T <toolset-name>            = Specify toolset name if supported by
                                 generator.
  -A <platform-name>           = Specify platform name if supported by
                                 generator.
  -Wdev                        = Enable developer warnings.
  -Wno-dev                     = Suppress developer warnings.
  -Werror=dev                  = Make developer warnings errors.
  -Wno-error=dev               = Make developer warnings not errors.
  -Wdeprecated                 = Enable deprecation warnings.
  -Wno-deprecated              = Suppress deprecation warnings.
  -Werror=deprecated           = Make deprecated macro and function warnings
                                 errors.
  -Wno-error=deprecated        = Make deprecated macro and function warnings
                                 not errors.
  -E                           = CMake command mode.
  -L[A][H]                     = List non-advanced cached variables.
  --build <dir>                = Build a CMake-generated project binary tree.
  -N                           = View mode only.
  -P <file>                    = Process script mode.
  --find-package               = Run in pkg-config like mode.
  --graphviz=[file]            = Generate graphviz of dependencies, see
                                 CMakeGraphVizOptions.cmake for more.
  --system-information [file]  = Dump information about this system.
  --debug-trycompile           = Do not delete the try_compile build tree.
                                 Only useful on one try_compile at a time.
  --debug-output               = Put cmake in a debug mode.
  --trace                      = Put cmake in trace mode.
  --trace-expand               = Put cmake in trace mode with variable
                                 expansion.
  --trace-source=<file>        = Trace only this CMake file/module.  Multiple
                                 options allowed.
  --warn-uninitialized         = Warn about uninitialized values.
  --warn-unused-vars           = Warn about unused variables.
  --no-warn-unused-cli         = Don't warn about command line options.
  --check-system-vars          = Find problems with variable usage in system
                                 files.
  --help,-help,-usage,-h,-H,/? = Print usage information and exit.
  --version,-version,/V [<f>]  = Print version number and exit.
  --help-full [<f>]            = Print all help manuals and exit.
  --help-manual <man> [<f>]    = Print one help manual and exit.
  --help-manual-list [<f>]     = List help manuals available and exit.
  --help-command <cmd> [<f>]   = Print help for one command and exit.
  --help-command-list [<f>]    = List commands with help available and exit.
  --help-commands [<f>]        = Print cmake-commands manual and exit.
  --help-module <mod> [<f>]    = Print help for one module and exit.
  --help-module-list [<f>]     = List modules with help available and exit.
  --help-modules [<f>]         = Print cmake-modules manual and exit.
  --help-policy <cmp> [<f>]    = Print help for one policy and exit.
  --help-policy-list [<f>]     = List policies with help available and exit.
  --help-policies [<f>]        = Print cmake-policies manual and exit.
  --help-property <prop> [<f>] = Print help for one property and exit.
  --help-property-list [<f>]   = List properties with help available and
                                 exit.
  --help-properties [<f>]      = Print cmake-properties manual and exit.
  --help-variable var [<f>]    = Print help for one variable and exit.
  --help-variable-list [<f>]   = List variables with help available and exit.
  --help-variables [<f>]       = Print cmake-variables manual and exit.

Generators

The following generators are available on this platform:
  Unix Makefiles               = Generates standard UNIX makefiles.
  Ninja                        = Generates build.ninja files.
  Watcom WMake                 = Generates Watcom WMake makefiles.
  CodeBlocks - Ninja           = Generates CodeBlocks project files.
  CodeBlocks - Unix Makefiles  = Generates CodeBlocks project files.
  CodeLite - Ninja             = Generates CodeLite project files.
  CodeLite - Unix Makefiles    = Generates CodeLite project files.
  Sublime Text 2 - Ninja       = Generates Sublime Text 2 project files.
  Sublime Text 2 - Unix Makefiles
                               = Generates Sublime Text 2 project files.
  Kate - Ninja                 = Generates Kate project files.
  Kate - Unix Makefiles        = Generates Kate project files.
  Eclipse CDT4 - Ninja         = Generates Eclipse CDT 4.0 project files.
  Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.
  KDevelop3                    = Generates KDevelop 3 project files.
  KDevelop3 - Unix Makefiles   = Generates KDevelop 3 project files.


● OpenCV CMake Error

 前回のビルドと喧嘩しているので全部消してやり直す。
CMake Error at cmake/OpenCVCompilerOptimizations.cmake:458 (message):
  Required baseline optimization is not supported: VFPV3
  (CPU_BASELINE_REQUIRE=;VFPV3;NEON)
Call Stack (most recent call first):
  cmake/OpenCVCompilerOptions.cmake:259 (include)
  CMakeLists.txt:555 (include)

CMake Error at cmake/OpenCVCompilerOptimizations.cmake:458 (message):
  Required baseline optimization is not supported: NEON
  (CPU_BASELINE_REQUIRE=;VFPV3;NEON)
Call Stack (most recent call first):
  cmake/OpenCVCompilerOptions.cmake:259 (include)
  CMakeLists.txt:555 (include)


● Raspberry Pi 3B+で最適化有無と libjpeg-turboでの OpenCVのベンチマーク

 SDカードを初期化して、下記のビルドをやり直しました。
 全く訳の分からない結果となりました。
 OpenCVのビルドごっこは飽きたのでもうやらない。
最適化有無
NEON VFP3 FAST-MATH
libjpeg実行時間(秒)
python3
ビルド時間(分)
無しlibjpeg.so (ver 62)12.36668分
無しlibjpeg-turbo ver 2.0.012.18287分
有りlibjpeg.so (ver 62)11.25596分

●最適化
    -D ENABLE_FAST_MATH=ON \
    -D ENABLE_NEON=ON \
    -D ENABLE_VFPV3=ON \

● libjpeg
    libjpeg.so (ver 62)
● libjpeg-turbo
    libjpeg-turbo (ver 1.5.3-62)
    /opt/libjpeg-turbo/lib32/libjpeg.a (ver 62)

● cmake ..

 JPEG、Raspbian OS Stretchの標準ライブラリ。
JPEG: /usr/lib/arm-linux-gnueabihf/libjpeg.so (ver 62)

 ARMv7用の最適化 VFPV3 NEONを有効にしない(disabled)
 GCCコンパイラ用の最適化指定 -ffast-mathを有効にしない(disabled)
-- General configuration for OpenCV 3.4.3 =====================================
--   Version control:               unknown
--
--   Platform:
--     Timestamp:                   2018-09-09T12:36:29Z
--     Host:                        Linux 4.14.50-v7+ armv7l
--     CMake:                       3.7.2
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               Release
...
--   CPU/HW features:
--     Baseline:
--       requested:                 DETECT
--       disabled:                  VFPV3 NEON
...
--     JPEG:                        /usr/lib/arm-linux-gnueabihf/libjpeg.so (ver 62)
...
--   Python 2:
--     Interpreter:                 /usr/bin/python2.7 (ver 2.7.13)
--     Libraries:                   /usr/lib/arm-linux-gnueabihf/libpython2.7.so (ver 2.7.13)
--     numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.12.1)
--     packages path:               lib/python2.7/dist-packages
--
--   Python 3:
--     Interpreter:                 /usr/bin/python3 (ver 3.5.3)
--     Libraries:                   /usr/lib/arm-linux-gnueabihf/libpython3.5m.so (ver 3.5.3)
--     numpy:                       /usr/lib/python3/dist-packages/numpy/core/include (ver 1.12.1)
--     packages path:               lib/python3.5/dist-packages
--
--   Python (for build):            /usr/bin/python2.7

real    67m50.429s
user    210m6.014s
sys     5m14.145s

pi@raspberrypi:~/opencv-3.4.3/build $ python opencv_test.py
3.4.3
imread time seconds: 12.527
pi@raspberrypi:~/opencv-3.4.3/build $ python opencv_test.py
3.4.3
imread time seconds: 12.387

pi@raspberrypi:~/opencv-3.4.3/build $ python3 opencv_test.py
3.4.3
imread time seconds: 12.411
pi@raspberrypi:~/opencv-3.4.3/build $ python3 opencv_test.py
3.4.3
imread time seconds: 12.366

cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D WITH_JPEG=ON \
    -D BUILD_JPEG=OFF \
    -D JPEG_INCLUDE_DIR=/opt/libjpeg-turbo/include \
    -D JPEG_LIBRARY=/opt/libjpeg-turbo/lib32/libjpeg.a \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.4.3/modules \
    -D BUILD_TESTS=OFF \
    -D INSTALL_PYTHON_EXAMPLES=OFF \
    -D BUILD_EXAMPLES=OFF ..

--   CPU/HW features:
--     Baseline:
--       requested:                 DETECT
--       disabled:                  VFPV3 NEON

--     JPEG:                        /opt/libjpeg-turbo/lib32/libjpeg.a (ver 62)

time make -j4

real    86m40.810s
user    207m34.015s
sys     5m52.039s

pi@raspberrypi:~/opencv-3.4.3/build $ python opencv_test.py
3.4.3
imread time seconds: 12.333
pi@raspberrypi:~/opencv-3.4.3/build $ python opencv_test.py
3.4.3
imread time seconds: 12.074

pi@raspberrypi:~/opencv-3.4.3/build $ python3 opencv_test.py
3.4.3
imread time seconds: 12.364
pi@raspberrypi:~/opencv-3.4.3/build $ python3 opencv_test.py
3.4.3
imread time seconds: 12.182


cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.4.3/modules \
    -D ENABLE_FAST_MATH=ON \
    -D ENABLE_NEON=ON \
    -D ENABLE_VFPV3=ON \
    -D BUILD_TESTS=OFF \
    -D INSTALL_PYTHON_EXAMPLES=OFF \
    -D BUILD_EXAMPLES=OFF ..

--   CPU/HW features:
--     Baseline:                    VFPV3 NEON
--       requested:                 DETECT
--       required:                  VFPV3 NEON

--     JPEG:                        /usr/lib/arm-linux-gnueabihf/libjpeg.so (ver 62)

time make -j4

real    95m54.876s
user    231m58.771s
sys     6m30.097s

pi@raspberrypi:~/opencv-3.4.3/build $ python opencv_test.py                     3.4.3
imread time seconds: 11.345
pi@raspberrypi:~/opencv-3.4.3/build $ python opencv_test.py
3.4.3
imread time seconds: 11.533

pi@raspberrypi:~/opencv-3.4.3/build $ python3 opencv_test.py
3.4.3
imread time seconds: 11.334
pi@raspberrypi:~/opencv-3.4.3/build $ python3 opencv_test.py
3.4.3
imread time seconds: 11.255



Tags: [Raspberry Pi], [電子工作]

●関連するコンテンツ(この記事を読んだ人は、次の記事も読んでいます)

Raspberry Pi 3B系のトラブルであるある第一位の電源トラブル、低電圧警報に関する情報のまとめ
Raspberry Pi 3B系のトラブルであるある第一位の電源トラブル、低電圧警報に関する情報のまとめ

  ラズパイ系での低電圧警報に関する情報まとめ、コマンドラインやログファイルから低電圧を検知する方法

Raspberry Piで CPUの脆弱性 Spectreと Meltdownの脆弱性をチェックする方法
Raspberry Piで CPUの脆弱性 Spectreと Meltdownの脆弱性をチェックする方法

  ラズパイで 2018年初頭に大騒ぎになったスペクターとメルトダウンの CPUの脆弱性をチェックする方法

Raspberry Pi Zero Wを海外通販の Pimoroni等での購入方法、購入出来る通販ショップ一覧まとめ
Raspberry Pi Zero Wを海外通販の Pimoroni等での購入方法、購入出来る通販ショップ一覧まとめ

  ラズパイゼロW ワイヤレスモデルを海外通販でサクッと簡単に個人輸入で入手。技適通過でも国内販売は常に品切れ

Raspberry Pi 3で安定して使える相性の無い最適な microSDカードの種類のまとめ
Raspberry Pi 3で安定して使える相性の無い最適な microSDカードの種類のまとめ

  ラズパイ3で安定して使える microSDカードを購入する Teamと SanDiskは絶対に買わない

Raspberry Pi 3 Model Bに専用カメラモジュール RaspiCamを接続する方法
Raspberry Pi 3 Model Bに専用カメラモジュール RaspiCamを接続する方法

  ラズパイに専用カメラモジュールを接続して Raspbianで写真の静止画撮影や動画を録画する方法

Raspberry Pi 3の Linuxコンソール上で使用する各種コマンドまとめ
Raspberry Pi 3の Linuxコンソール上で使用する各種コマンドまとめ

  ラズパイの Raspbian OSのコマンドラインで使用する便利コマンド、負荷試験や CPUシリアル番号の確認方法等も

Raspberry Pi 3公式フォーラムの FAQの内容の日本語訳
Raspberry Pi 3公式フォーラムの FAQの内容の日本語訳

  ラズパイ公式フォーラムの「The Raspberry Pi 3 Model B Q&A thread」の日本語訳

Raspberry Pi 3で GPIO端子の I2C機能を有効化する方法
Raspberry Pi 3で GPIO端子の I2C機能を有効化する方法

  ラズパイ3の GPIO端子の I2C機能を有効にして各種センサーを繋げる方法まとめ

大人気の CPUボード、Raspberry Pi 3 Model Bで作ってみよう
大人気の CPUボード、Raspberry Pi 3 Model Bで作ってみよう

  Raspberry Piの開発環境の構築やタッチパネル付き液晶ディスプレイや各種センサーの使い方まとめ


Raspberry Pi 3、シングルボードコンピュータ ラズパイ3 Raspberry Pi関連はこちらへまとめました
 下記以外にも多数のラズパイ関係の記事が有ります。
 (I2C制御、GPIO制御、1-Wire制御、シリアル通信、日本語音声合成、日本語音声認識、中国語音声合成、MeCab 形態素解析エンジン、赤外線リモコン制御、秋月 I2C液晶モジュール、KeDei 3.5インチ液晶、HDMI 5インチ液晶、NFCカードリーダ、コマンドライン操作方法等)
Raspberry Pi 3に HDMI接続の 800x480 5インチ TFT液晶を接続して使用する方法
Raspbian Jessie 2017-07最終版で LIRCを使って学習リモコン、赤外線リモコンを送受信する方法
Raspberry Pi 3の WiFiを広告ブロック機能付きの無線LANアクセスポイント化 hostapd + dnsmasq編
Raspberry Pi 3の Bluetoothで ブルテザで通信する方法(Bluetooth編)
Raspberry Pi 3で日本語音声を合成して喋らせる方法(OpenJTalk編)
Raspberry Pi 3に USB Micを接続して日本語の音声認識をする方法(Julius編)
Raspberry Pi 3の GPIOに LEDとスイッチを接続して Lチカする方法
Raspberry Pi 3の GPIOに LEDとスイッチを接続してシャットダウンボタンを実装する方法
Raspberry Pi 3で GPIO端子の I2C機能を有効化する方法
Raspberry Pi 3の GPIOに I2C通信方式の気圧計 BMP280を接続する方法
Raspberry Pi 3に I2C通信方式の NFCリーダライタ PN532を接続して NFC FeliCaカードを読む方法
Raspberry Pi 3でネットワーク ライブカメラを構築する方法 Motion編
Raspberry Pi 3でネットワーク ライブカメラを構築する方法 MJPG-streamer編
Raspberry Pi 3 Model Bで動画処理アプリ FFmpegをコンパイルする方法
Raspberry Pi3の X-Window Systemに Windowsのリモートデスクトップから接続する方法
Raspberry Pi3に WebRTCの STUN/TRUNサーバと PeerJSサーバをインストールする方法
【成功版】Raspberry Piで NNPACK対応版の Darknet Neural Network Frameworkをビルドする方法


Espressif ESP8266 Arduino互換でスケッチが使える ESP-12Eモジュール基板
Espressif ESP8266 Arduino互換でスケッチが使える ESP-12Eモジュール基板

  Espressif ESP8266 ESP-12-E NodeMCU V1 ESP12 CP2102

BangGood通販はドローン以外にも面白い商品がまだまだ有った(電子工作編)
BangGood通販はドローン以外にも面白い商品がまだまだ有った(電子工作編)

  レーザー彫刻機、カラー液晶の DIYオシロ、Arduinoや Raspberry Pi用の小型カラー液晶



[HOME] | [BACK]
リンクフリー(連絡不要、ただしトップページ以外はweb構成の変更で移動する場合があります)
Copyright (c) 2018 FREE WING, Y.Sakamoto
Powered by 猫屋敷工房 & HTML Generator

http://www.neko.ne.jp/~freewing/raspberry_pi/raspberry_pi_optimize_opencv_for_pi_3_neon_vfp3/