I was working on Canny Edge Detector. After reading the source code, I felt like the edge detector could work in one way among IPP/OPENCL/OPENVX/CV_SIMD(which uses, TBB, I think)/the most traditional and slowest way(to work on pixels one by one). However, I only wanted it parallelCanny with CV_SIMD defined to work.
I tried to call canny function and use "std::cout << cv::getBuildInformation() << std::endl;" to see the libraries being used in the process. Then, I wrote a short CMakeLists.txt file in this way:
# project name
PROJECT(opencv_test)
# requirement of cmake version
cmake_minimum_required(VERSION 3.9)
add_compile_options(-std=c++17)
# find required opencv
find_package(OpenCV REQUIRED)
# name of executable file and path of source file
add_executable(opencv_test main.cpp)
# opencv libraries
target_link_libraries(opencv_test ${OpenCV_LIBS})
After that, I ran the program with the following command in order:
cmake -D WITH_OPENCL=OFF -D WITH_IPP=OFF -D WITH_TBB=OFF -D WITH_OPENMP=ON .
make
opencv_test
Only to be told that:
CMake Warning:
Manually-specified variables were not used by the project:
WITH_IPP
WITH_OPENCL
WITH_OPENMP
WITH_TBB
Then, after my program ran, the line of code
std::cout << cv::getBuildInformation() << std::endl;
printed out exactly the same things as I ran cmake command without any options as follows (I also wrote another function to check if CV_SIMD is enabled):
================== macro dump ===================
CV_SIMD is NOT defined
SIMD intrinsics are not available. Check compilation target and passed build options.
===================== done ======================
General configuration for OpenCV 4.1.1 =====================================
Version control: unknown
Extra modules:
Location (extra): /tmp/opencv-20190826-34514-r5q5gz/opencv-4.1.1/opencv_contrib/modules
Version control (extra): unknown
Platform:
Timestamp: 2019-08-26T13:40:01Z
Host: Darwin 18.6.0 x86_64
CMake: 3.15.2
CMake generator: Unix Makefiles
CMake build tool: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/gmake
Configuration: Release
CPU/HW features:
Baseline: SSE SSE2 SSE3 SSSE3 SSE4_1 POPCNT SSE4_2
requested: DETECT
disabled: AVX AVX2
Dispatched code generation: FP16 AVX AVX2 AVX512_SKX
requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
FP16 (0 files): + FP16 AVX
AVX (4 files): + AVX
AVX2 (27 files): + FP16 FMA3 AVX AVX2
AVX512_SKX (2 files): + FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
C/C++:
Built as dynamic libs?: YES
C++ Compiler: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang++ (ver 10.0.1.10010046)
C++ flags (Release): -I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include/darwin -fsigned-char -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 -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -DNDEBUG -DNDEBUG
C++ flags (Debug): -I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include/darwin -fsigned-char -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 -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
C Compiler: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang
C flags (Release): -I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include/darwin -fsigned-char -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 -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -DNDEBUG -DNDEBUG
C flags (Debug): -I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include/darwin -fsigned-char -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 -Wsign-promo -Wuninitialized -Winit-self -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release): -Wl,-dead_strip
Linker flags (Debug): -Wl,-dead_strip
ccache: NO
Precompiled headers: NO
Extra dependencies:
3rdparty dependencies:
OpenCV modules:
To be built: aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dpm face features2d flann freetype fuzzy gapi hfs highgui img_hash imgcodecs imgproc line_descriptor ml objdetect optflow phase_unwrapping photo plot python2 python3 quality reg rgbd saliency sfm 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 matlab ovis ts viz
Applications: apps
Documentation: NO
Non-free algorithms: YES
GUI:
Cocoa: YES
Media I/O:
ZLib: /usr/lib/libz.dylib (ver 1.2.11)
JPEG: build-libjpeg-turbo (ver 2.0.2-62)
WEBP: build (ver encoder: 0x020e)
PNG: /usr/local/lib/libpng.dylib (ver 1.6.37)
TIFF: /usr/local/lib/libtiff.dylib (ver 42 / 4.0.10)
OpenEXR: /usr/local/lib/libImath.dylib /usr/local/lib/libIlmImf.dylib /usr/local/lib/libIex.dylib /usr/local/lib/libHalf.dylib /usr/local/lib/libIlmThread.dylib (ver 2.3.0)
HDR: YES
SUNRASTER: YES
PXM: YES
PFM: YES
Video I/O:
FFMPEG: YES
avcodec: YES (58.35.100)
avformat: YES (58.20.100)
avutil: YES (56.22.100)
swscale: YES (5.3.100)
avresample: YES (4.0.0)
AVFoundation: YES
Parallel framework: TBB (ver 2019.0 interface 11008)
Trace: YES (with Intel ITT)
Other third-party libraries:
Intel IPP: 2019.0.0 Gold [2019.0.0]
at: /tmp/opencv-20190826-34514-r5q5gz/opencv-4.1.1/build/3rdparty/ippicv/ippicv_mac/icv
Intel IPP IW: sources (2019.0.0)
at: /tmp/opencv-20190826-34514-r5q5gz/opencv-4.1.1/build/3rdparty/ippicv/ippicv_mac/iw
Lapack: YES (/usr/local/opt/openblas/lib/libopenblas.dylib)
Eigen: YES (ver 3.3.7)
Custom HAL: NO
Protobuf: build (3.5.1)
OpenCL: YES (no extra features)
Include path: NO
Link libraries: -framework OpenCL
Python 2:
Interpreter: /usr/local/opt/python@2/bin/python (ver 2.7.16)
Libraries: /
usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib (ver 2.7.16)
numpy: /usr/local/lib/python2.7/site-packages/numpy/core/include (ver 1.16.4)
install path: lib/python2.7/site-packages/cv2/python-2.7
Python 3:
Interpreter: /usr/local/opt/python/bin/python3 (ver 3.7.4)
Libraries: /usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin/libpython3.7.dylib (ver 3.7.4)
numpy: /usr/local/lib/python3.7/site-packages/numpy/core/include (ver 1.16.4)
install path: lib/python3.7/site-packages/cv2/python-3.7
Python (for build): /usr/local/opt/python@2/bin/python
Java:
ant: NO
JNI: /Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include /Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include/darwin /Library/Java/JavaVirtualMachines/adoptopenjdk-12.0.1.jdk/Contents/Home/include
Java wrappers: NO
Java tests: NO
Install to: /usr/local/Cellar/opencv/4.1.1
-----------------------------------------------------------------
I also tried many other options such as to write "set(WITH_OPENCL OFF)" in CMakeLists.txt or "setUseOptimized(false);" in my main function. But none of them worked. I wonder what caused the above situation where OPENCL and IPP can never be disabled but CV_SIMD can never be enabled? Is it because I misunderstand anything and use Cmake + its options in a wrong way? How can I correct it? Or is it because I was using OPENCV 4.1.1 and CMake 3.15 (both of which are new versions) and my operating system is macOS 10.15, which is a quite buggy system?
Could anyone please offer me some hints, such as to correct my understanding in Canny source code, or, more importantly, to show me how to disable OPENCL/IPP and other modules except OPENMP, and check whether those options take effect after that?
Thanks a lot for any possible hints!