LoginSignup
1
2

More than 1 year has passed since last update.

OpenCV4.5.4ビルドログ(Windows+Visual Studio2019)

Last updated at Posted at 2021-12-12

はじめに

この記事は,2020年のアドベントカレンダーに空いていた隙間を1年越しに埋めた記事です.
上のリボンを押してもOpenCVアドベントカレンダー2021にはリンクしません.
1年後でも投稿できるんですね...

OpenCV4.5.4を,Windows+VisualStudio2019でコンパイルしたログです.
OpenCV4.5.4は,コンパイルしている時点では最新ですが,そろそろ4.5.5が出そうな雰囲気です...

前回(去年)と違って,何もしなくてもすんなりコンパイルできました.

注意書き

highguiの使い方の推奨が変わり,下記のように初期化してトラックバーを作ると怒られるようになりました.

int sw = 0; 
createTrackbar("swich", "window", &sw, 1);
[WARN:0] global C : \opencv - 4.5.4\modules\highgui\src\window.cpp(704) 
cv::createTrackbar UI / Trackbar(ymax@data) : 
Using 'value' pointer is unsafe and deprecated.
Use NULL as value pointer.To fetch trackbar value setup callback.

引数1の後にコールバック関数のポインタを指定するのですが(この場合はNULLを指定),初期値は,そこで初期化しろということでしょうか.
ひとまず,opencv内のこのコードを出力している部分を修正するか,書き方を修正して,このワーニングを出ないようにしないとprintfデバッグが死にます.

GUI作るところでは,中身を持たず,こうしろということ?

void func()
{
//swを確保するような処理
}

int main()
{
int* sw = nullptr; 
createTrackbar("swich", "window", sw, 1, func);
...
}

コンパイル対象

コンパイル環境

  • CPU Intel Core i9 10980XE
  • Visual Studio 2019

コンパイルするOpenCVの状態
コンパイルしたものは以下です.

  • 通常のモジュール
  • contribモジュール
  • With Qt (Qt5.12.12)
  • With Eigen (Eigen3.4)
  • Non-free algorithms: YES
  • OPENCV_IPP_GAUSSIAN_BLUR
    • enable IPP optimization for GaussianBlur (+8Mb in binary size)

目立ったところだとCUDAとPythonをOnにしていません.
Pythonは普段全く使わないため入れていませんが,C++のをバインディングしているだけなので,これのコンパイルでこけることはまずないでしょう.

CUDAのコンパイルは,毎回魔境です.CUDAで実行したくなることがまれなため,必要になるまでコンパイルしません.

CPUは全バージョンでコンパイルしています.
CPUのディスパッチは,全バージョンに対応させるとちょっとだけコンパイル時間が長くなります.
8年以上前のIntel CPU使っている人(ivy bridge以前)以外は,AVX2だけでいいはずです.
なお,コンパイルしているこのマシンはAVX-512に対応しているサーバー機なのでAVX512-SKXだけでいいですが,研究室全体にコンパイル済みのを配置するので全部コンパイルしてます.
SKXはおそらくSkylakeXの略ですが,intrinsicに特殊な命令を対応させていないので,Skaylake-SPやIcelake系(IcelakeやIcelake-
SP,TigerlakeやRocketlake)でも,AVX-512対応のCPUなら今のところ全部このオプションでいいと思われます.

Qtは,去年の記事と違って,cmakeにオプションがあるため,たぶん6に対応してます.
が,5系で試しました.(OpenCVのWith Qtオプションは新しいバージョンにしても恩恵まったくないです.)
コンパイルの時は,下記等,qmakeのある場所にパスを必ず通しましょう.

C:\Qt\5.12.12\msvc2017_64\bin

Eigenはヘッダの場所を指定したら見つけてくれるはずです.
With Eigen (Eigen3.4)
毎回Eigen3_DIRが見つかりませんをはきますが,そこにヘッダのディレクトリを指定したら大丈夫です.
(どこに書いておけばこのエラー抑制できるのでしょう.困ったことがないので毎回指定しています)

OPENCV_IPP_GAUSSIAN_BLURオプションは完全オレ得オプションです.
普通の人はガウシアンフィルタがちょっと速くなってもどうでもいいでしょう.

線形代数のBLASやLAPACKは入れてもいいのですが,あえてOpenCVから呼ぶ気がしないので入れません.

CMakeのログ

下記cmakeのログです.
CUDAを入れていないのでCUDA関係が全滅です.
また,VTKなどのいくつかの外部ライラリ入れていないので下記が無効化されています.(Python除いて,ほとんど出番はない)
cvv freetype hdf java julia matlab ovis python2 python3 sfm viz

Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
Detected processor: AMD64
Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "2.7")
Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "3.2")
libjpeg-turbo: VERSION = 2.1.0, BUILD = opencv-4.5.4-libjpeg-turbo
Could NOT find OpenJPEG (minimal suitable version: 2.0, recommended version >= 2.3.1). OpenJPEG will be built from sources
OpenJPEG: VERSION = 2.4.0, BUILD = opencv-4.5.4-openjp2-2.4.0
OpenJPEG libraries will be built from sources: libopenjp2 (version "2.4.0")
found Intel IPP (ICV version): 2020.0.0 [2020.0.0 Gold]
at: C:/Users/fukushima/Desktop/opencv-4.5.4/build/3rdparty/ippicv/ippicv_win/icv
found Intel IPP Integration Wrappers sources: 2020.0.0
at: C:/Users/fukushima/Desktop/opencv-4.5.4/build/3rdparty/ippicv/ippicv_win/iw
Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
Could NOT find BLAS (missing: BLAS_LIBRARIES) 
Could NOT find LAPACK (missing: LAPACK_LIBRARIES) 
    Reason given by package: LAPACK could not be found because dependency BLAS could not be found.

Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) 
VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
freetype2:   NO
harfbuzz:    NO
Julia not found. Not compiling Julia Bindings. 
Module opencv_ovis disabled because OGRE3D was not found
OpenCV Python: during development append to PYTHONPATH: C:/Users/fukushima/Desktop/opencv-4.5.4/build/python_loader
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
Tesseract:   NO
Allocator metrics storage type: 'long long'
Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': C:/Users/fukushima/Desktop/opencv-4.5.4/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
opencv_dnn: filter out cuda4dnn source code
Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.rvv.cpp
highgui: using builtin backend: QT5

General configuration for OpenCV 4.5.4 =====================================
  Version control:               unknown

  Platform:
    Timestamp:                   2021-12-08T01:10:35Z
    Host:                        Windows 10.0.19042 AMD64
    CMake:                       3.22.1
    CMake generator:             Visual Studio 16 2019
    CMake build tool:            C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/MSBuild/Current/Bin/MSBuild.exe
    MSVC:                        1929
    Configuration:               Debug 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 (17 files):         + SSSE3 SSE4_1
      SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
      FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (5 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (32 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
      AVX512_SKX (8 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:                C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe  (ver 19.29.30137.0)
    C++ flags (Release):         /DWIN32 /D_WINDOWS /W4 /GR  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP  /MD /O2 /Ob2 /DNDEBUG 
    C++ flags (Debug):           /DWIN32 /D_WINDOWS /W4 /GR  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP  /MDd /Zi /Ob0 /Od /RTC1 
    C Compiler:                  C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe
    C flags (Release):           /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /MP   /MD /O2 /Ob2 /DNDEBUG 
    C flags (Debug):             /DWIN32 /D_WINDOWS /W3  /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi  /fp:precise     /MP /MDd /Zi /Ob0 /Od /RTC1 
    Linker flags (Release):      /machine:x64  /INCREMENTAL:NO 
    Linker flags (Debug):        /machine:x64  /debug /INCREMENTAL 
    ccache:                      NO
    Precompiled headers:         YES
    Extra dependencies:
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 alphamat aruco barcode bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype hdf java julia matlab ovis python2 python3 sfm viz
    Applications:                tests perf_tests apps
    Documentation:               NO
    Non-free algorithms:         YES

  Windows RT support:            NO

  GUI:                           QT5
    QT:                          YES (ver 5.12.12 )
      QT OpenGL support:         NO
    Win32 UI:                    YES
    VTK support:                 NO

  Media I/O: 
    ZLib:                        build (ver 1.2.11)
    JPEG:                        build-libjpeg-turbo (ver 2.1.0-62)
    WEBP:                        build (ver encoder: 0x020f)
    PNG:                         build (ver 1.6.37)
    TIFF:                        build (ver 42 - 4.2.0)
    JPEG 2000:                   build (ver 2.4.0)
    OpenEXR:                     build (ver 2.3.0)
    HDR:                         YES
    SUNRASTER:                   YES
    PXM:                         YES
    PFM:                         YES

  Video I/O:
    DC1394:                      NO
    FFMPEG:                      YES (prebuilt binaries)
      avcodec:                   YES (58.134.100)
      avformat:                  YES (58.76.100)
      avutil:                    YES (56.70.100)
      swscale:                   YES (5.9.100)
      avresample:                YES (4.0.0)
    GStreamer:                   NO
    DirectShow:                  YES
    Media Foundation:            YES
      DXVA:                      YES

  Parallel framework:            Concurrency

  Trace:                         YES (with Intel ITT)

  Other third-party libraries:
    Intel IPP:                   2020.0.0 Gold [2020.0.0]
           at:                   C:/Users/fukushima/Desktop/opencv-4.5.4/build/3rdparty/ippicv/ippicv_win/icv
    Intel IPP IW:                sources (2020.0.0)
              at:                C:/Users/fukushima/Desktop/opencv-4.5.4/build/3rdparty/ippicv/ippicv_win/iw
    Lapack:                      NO
    Eigen:                       YES (ver 3.4.0)
    Custom HAL:                  NO
    Protobuf:                    build (3.5.1)

  OpenCL:                        YES (NVD3D11)
    Include path:                C:/Users/fukushima/Desktop/opencv-4.5.4/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python (for build):            NO

  Java:                          
    ant:                         NO
    JNI:                         NO
    Java wrappers:               NO
    Java tests:                  NO

  Install to:                    C:/Users/fukushima/Desktop/opencv-4.5.4/build/install
-----------------------------------------------------------------

Configuring done
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2