I'm implementing a video stitching paper and using CMake to generate make file. It seems like CMake is somehow failed to pass correct args for compiler when it compiles a code with OpenCV's stitching module (especially blender part). The make progress stops with this error:
/usr/bin/c++ -DOPENCV_TRAITS_ENABLE_DEPRECATED -I/home/kra/dev/Stitcher/include -isystem /usr/local/include -isystem /usr/local/include/opencv -Wall -Wextra -O3 -DNDEBUG -std=gnu++11 -o CMakeFiles/stitcher.dir/src/solver.cpp.o -c /home/kra/dev/Stitcher/src/solver.cpp
In file included from /usr/include/c++/5/vector:64:0,
from /usr/include/c++/5/bits/random.h:34,
from /usr/include/c++/5/random:49,
from /usr/include/c++/5/bits/stl_algo.h:66,
from /usr/include/c++/5/algorithm:62,
from /usr/local/include/opencv2/core/base.hpp:55,
from /usr/local/include/opencv2/core.hpp:54,
from /usr/local/include/opencv2/stitching/detail/blenders.hpp:50,
from /home/kra/dev/Stitcher/src/utilities.cpp:1:
/usr/include/c++/5/bits/stl_vector.h: In instantiation of ‘std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = cv::cuda::GpuMat; _Alloc = std::allocator<cv::cuda::GpuMat>]’:
/usr/include/c++/5/bits/stl_vector.h:425:33: required from ‘std::vector<_Tp, _Alloc>::~vector() [with _Tp = cv::cuda::GpuMat; _Alloc = std::allocator<cv::cuda::GpuMat>]’
/usr/local/include/opencv2/stitching/detail/blenders.hpp:126:18: required from here
/usr/include/c++/5/bits/stl_vector.h:161:9: error: invalid use of incomplete type ‘class cv::cuda::GpuMat’
- this->_M_impl._M_start); }
^
In file included from /usr/local/include/opencv2/core.hpp:54:0,
from /usr/local/include/opencv2/stitching/detail/blenders.hpp:50,
from /home/kra/dev/Stitcher/src/utilities.cpp:1:
/usr/local/include/opencv2/core/base.hpp:717:22: note: forward declaration of ‘class cv::cuda::GpuMat’
class CV_EXPORTS GpuMat;
Ubuntu 16.04
OpenCV 3.4.1
My CMake looks like below:
CMAKE_MINIMUM_REQUIRED (VERSION 3.2)
PROJECT(VideoStitcher CXX)
FIND_PACKAGE(OpenCV REQUIRED)
INCLUDE_DIRECTORIES(include)
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_VERBOSE_MAKEFILE ON)
if(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release)
endif()
SET(CMAKE_CXX_FLAGS "-Wall -Wextra")
FILE(GLOB all_sources "src/*.cpp")
ADD_EXECUTABLE(stitcher ${all_sources})
TARGET_LINK_LIBRARIES(
stitcher
boost_filesystem
boost_system
${OpenCV_LIBS}
)
It's weird because OpenCV successfully built all CPP examples and I can even build stitching_detailed.cpp example with CMake similar to above. Below is my OpenCV build info:
-- General configuration for OpenCV 3.4.1 =====================================
-- Version control: 3.4.1
--
-- Extra modules:
-- Location (extra): /home/kra/Softwares/opencv_contrib/modules
-- Version control (extra): 3.4.1-dirty
--
-- Platform:
-- Timestamp: 2018-06-06T22:48:37Z
-- Host: Linux 4.13.0-43-generic x86_64
-- CMake: 3.5.2
-- CMake generator: Unix Makefiles
-- CMake build tool: /usr/bin/make
-- Configuration: RelWithDebInfo
--
-- 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 (3 files): + SSSE3 SSE4_1
-- SSE4_2 (1 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 (9 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
-- AVX512_SKX (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_SKX
--
-- C/C++:
-- Built as dynamic libs?: YES
-- C++ Compiler: /usr/bin/c++ (ver 5.4.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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -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=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-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=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 -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
-- Linker flags (Release):
-- Linker flags (Debug):
-- ccache: NO
-- Precompiled headers: YES
-- Extra dependencies: dl m pthread rt cudart nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/local/cuda-8.0/lib64
-- 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 datasets dnn dnn_objdetect dpm face features2d flann freetype fuzzy hdf hfs highgui img_hash imgcodecs imgproc java_bindings_generator line_descriptor ml objdetect optflow phase_unwrapping photo plot python3 python_bindings_generator reg rgbd saliency sfm shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
-- Disabled: js world
-- Disabled by dependency: -
-- Unavailable: cnn_3dobj cvv dnn_modern java matlab ovis python2 ts viz
-- Applications: examples apps
-- Documentation: NO
-- Non-free algorithms: NO
--
-- GUI:
-- GTK+: YES (ver 3.18.9)
-- GThread : YES (ver 2.48.2)
-- GtkGlExt: NO
-- VTK support: NO
--
-- Media I/O:
-- ZLib: /home/kra/Softwares/anaconda3/lib/libz.so (ver 1.2.11)
-- JPEG: /home/kra/Softwares/anaconda3/lib/libjpeg.so (ver 90)
-- WEBP: build (ver encoder: 0x020e)
-- PNG: /home/kra/Softwares/anaconda3/lib/libpng.so (ver 1.6.32)
-- TIFF: /home/kra/Softwares/anaconda3/lib/libtiff.so (ver 42 / 4.0.8)
-- JPEG 2000: /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
-- OpenEXR: build (ver 1.7.1)
--
-- Video I/O:
-- DC1394: NO
-- FFMPEG: YES
-- avcodec: YES (ver 56.60.100)
-- avformat: YES (ver 56.40.101)
-- avutil: YES (ver 54.31.100)
-- swscale: YES (ver 3.1.101)
-- avresample: NO
-- GStreamer: NO
-- libv4l/libv4l2: NO
-- v4l/v4l2: linux/videodev2.h
-- gPhoto2: NO
--
-- Parallel framework: pthreads
--
-- Trace: YES (with Intel ITT)
--
-- Other third-party libraries:
-- Intel IPP: 2017.0.3 [2017.0.3]
-- at: /home/kra/Softwares/opencv/build/3rdparty/ippicv/ippicv_lnx
-- Intel IPP IW: sources (2017.0.3)
-- at: /home/kra/Softwares/opencv/build/3rdparty/ippicv/ippiw_lnx
-- Lapack: NO
-- Eigen: YES (ver 3.2.92)
-- Custom HAL: NO
-- Protobuf: build (3.5.1)
--
-- NVIDIA CUDA: YES (ver 8.0, CUFFT CUBLAS)
-- NVIDIA GPU arch: 20 30 35 37 50 52 60 61
-- NVIDIA PTX archs:
--
-- OpenCL: YES (no extra features)
-- Include path: /home/kra/Softwares/opencv/3rdparty/include/opencl/1.2
-- Link libraries: Dynamic load
--
-- Python 3:
-- Interpreter: /home/kra/Softwares/anaconda3/bin/python3 (ver 3.6.2)
-- Libraries: /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1 (ver 3.6.2)
-- numpy: /home/kra/Softwares/anaconda3/lib/python3.6/site-packages/numpy/core/include (ver 1.13.3)
-- packages path: lib/python3.6/site-packages
--
-- Python (for build): /home/kra/Softwares/anaconda3/envs/oc/bin/python3.5
-- Pylint: /home/kra/Softwares/anaconda3/bin/pylint (ver: 1.7.2, checks: 116)
--
-- Java:
-- ant: NO
-- JNI: NO
-- Java wrappers: NO
-- Java tests: NO
--
-- Install to: /usr/local
-- -----------------------------------------------------------------
I tried various method to add CUDA to CMake but no luck. I can't find similar problem on Internet either.
Related
I configured OpenCV 3.4.11 according to this post.
I am using MingGW as my compiler.
Here is what CMake GUI told me:
Detected processor: AMD64
sizeof(void) = 4 on 64 bit processor. Assume 32-bit compilation mode
libjpeg-turbo: VERSION = 2.0.5, BUILD = opencv-3.4.11-libjpeg-turbo
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)
LAPACK requires BLAS
A library with LAPACK API not found. Please specify library location.
Found apache ant: C:/apache-ant-1.10.8/bin/ant.bat (1.8.0)
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
OpenCV Python: during development append to PYTHONPATH: D:/mingw-build-3.4.11/python_loader
Caffe: NO
Protobuf: NO
Glog: NO
freetype2: NO
harfbuzz: NO
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: Eigen Glog/Gflags
Allocator metrics storage type: 'int'
Excluding from source files list: modules/imgproc/src/imgwarp.avx2.cpp
Excluding from source files list: modules/imgproc/src/resize.avx2.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 3.4.11 =====================================
Version control: unknown
Extra modules:
Location (extra): D:/opencv_contrib-3.4.11/modules
Version control (extra): unknown
Platform:
Timestamp: 2020-08-15T06:52:46Z
Host: Windows 10.0.18363 AMD64
CMake: 3.18.1
CMake generator: MinGW Makefiles
CMake build tool: C:/MinGW/bin/mingw32-make.exe
Configuration: Release
CPU/HW features:
Baseline: SSE SSE2
requested: SSE2
Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX
requested: SSE4_1 SSE4_2 AVX FP16
SSE4_1 (14 files): + SSE3 SSSE3 SSE4_1
SSE4_2 (1 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2
FP16 (0 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
AVX (5 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 AVX
C/C++:
Built as dynamic libs?: NO
C++11: YES
C++ Compiler: C:/Strawberry/c/bin/g++.exe (ver 4.9.2)
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 -Wno-delete-non-virtual-dtor -Wno-comment -Wno-missing-field-initializers -fdiagnostics-show-option -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -mfpmath=sse -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 -Wno-delete-non-virtual-dtor -Wno-comment -Wno-missing-field-initializers -fdiagnostics-show-option -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -mfpmath=sse -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
C Compiler: C:/Strawberry/c/bin/gcc.exe
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 -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wno-missing-field-initializers -fdiagnostics-show-option -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -mfpmath=sse -fvisibility=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 -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wno-missing-field-initializers -fdiagnostics-show-option -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -mfpmath=sse -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: comctl32 gdi32 ole32 setupapi ws2_32 winmm
3rdparty dependencies: libprotobuf zlib libjpeg-turbo libwebp libpng libtiff libjasper IlmImf quirc
OpenCV modules:
To be built: aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dpm face features2d flann fuzzy hfs highgui img_hash imgcodecs imgproc line_descriptor ml objdetect optflow phase_unwrapping photo plot reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
Disabled: python_bindings_generator python_tests world
Disabled by dependency: -
Unavailable: cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype hdf java js matlab ovis python2 python3 sfm viz
Applications: apps
Documentation: NO
Non-free algorithms: NO
Windows RT support: NO
GUI:
Win32 UI: YES
VTK support: NO
Media I/O:
ZLib: build (ver 1.2.11)
JPEG: build-libjpeg-turbo (ver 2.0.5-62)
WEBP: build (ver encoder: 0x020f)
PNG: build (ver 1.6.37)
TIFF: build (ver 42 - 4.0.10)
JPEG 2000: build (ver 1.900.1)
OpenEXR: build (ver 2.3.0)
HDR: YES
SUNRASTER: YES
PXM: YES
Video I/O:
DC1394: NO
FFMPEG: YES (prebuilt binaries)
avcodec: YES (ver 57.107.100)
avformat: YES (ver 57.83.100)
avutil: YES (ver 55.78.100)
swscale: YES (ver 4.8.100)
avresample: YES (ver 3.7.0)
GStreamer: NO
DirectShow: YES
Parallel framework: none
Trace: YES (built-in)
Other third-party libraries:
Lapack: NO
Eigen: NO
Custom HAL: NO
Protobuf: build (3.5.1)
OpenCL: YES (no extra features)
Include path: D:/opencv-3.4.11/sources/3rdparty/include/opencl/1.2
Link libraries: Dynamic load
Python (for build): C:/Users/Administrator/AppData/Local/Programs/Python/Python38-32/python.exe
Java:
ant: C:/apache-ant-1.10.8/bin/ant.bat (ver 1.8.0)
JNI: NO
Java wrappers: NO
Java tests: NO
Install to: D:/mingw-build-3.4.11/install
-----------------------------------------------------------------
Configuring done
After applying mingw32-make -j8 and mingw32-make install in CMD, it built successfully.
Then, I add D:\mingw-build-3.4.11\install\x64\mingw\bin to my System PATH and restarted my computer.
The step 10 tells me to download FindOpenCV.cmake and add it to project-root/cmake/. However, this link responsed 502 Bad Gateway, thus I jumped over this step.
The following is my project contents:
CMakeLists.txt
cmake_minimum_required(VERSION 3.6)
project(opencv)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
# Where to find CMake modules and OpenCV
set(OpenCV_DIR "D:\\mingw-build-3.4.11\\install")
find_package(OpenCV REQUIRED core highgui imgproc imgcodecs)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(opencv opencv.cpp)
# add libs you need
set(OpenCV_LIBS opencv_core opencv_imgproc opencv_highgui opencv_imgcodecs)
# linking
target_link_libraries(opencv ${OpenCV_LIBS})
opencv.cpp
#include <opencv2/opencv.hpp>
using namespace cv;
int main() {
Mat mat = imread("1.jpg");
imshow("1", mat);
}
CMake build successfully like following:
"D:\Program Files\JetBrains\CLion 2020.1.2\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" D:\Users\Administrator\Documents\Codes\CLionProjects\opencv
-- OpenCV ARCH: x64
-- OpenCV RUNTIME: mingw
-- OpenCV STATIC: OFF
-- Found OpenCV 3.4.11 in D:/mingw-build-3.4.11/install/x64/mingw/lib
-- You might need to add D:/mingw-build-3.4.11/install/x64/mingw/bin to your PATH to be able to run your applications.
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Users/Administrator/Documents/Codes/CLionProjects/opencv/cmake-build-debug
[Finished]
However, everytime I run this application, compiler keeps telling me:
====================[ Build | opencv | Debug ]==================================
"D:\Program Files\JetBrains\CLion 2020.1.2\bin\cmake\win\bin\cmake.exe" --build D:\Users\Administrator\Documents\Codes\CLionProjects\opencv\cmake-build-debug --target opencv -- -j 4
[ 50%] Linking CXX executable opencv.exe
CMakeFiles\opencv.dir/objects.a(opencv.cpp.obj): In function `main':
D:/Users/Administrator/Documents/Codes/CLionProjects/opencv/opencv.cpp:6: undefined reference to `cv::imread(cv::String const&, int)'
D:/Users/Administrator/Documents/Codes/CLionProjects/opencv/opencv.cpp:7: undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
CMakeFiles\opencv.dir/objects.a(opencv.cpp.obj): In function `cv::String::String(char const*)':
D:/mingw-build-3.4.11/install/include/opencv2/core/cvstd.hpp:602: undefined reference to `cv::String::allocate(unsigned long long)'
CMakeFiles\opencv.dir/objects.a(opencv.cpp.obj): In function `cv::String::~String()':
D:/mingw-build-3.4.11/install/include/opencv2/core/cvstd.hpp:648: undefined reference to `cv::String::deallocate()'
CMakeFiles\opencv.dir/objects.a(opencv.cpp.obj): In function `cv::String::operator=(cv::String const&)':
D:/mingw-build-3.4.11/install/include/opencv2/core/cvstd.hpp:656: undefined reference to `cv::String::deallocate()'
CMakeFiles\opencv.dir/objects.a(opencv.cpp.obj): In function `cv::Mat::~Mat()':
D:/mingw-build-3.4.11/install/include/opencv2/core/mat.inl.hpp:786: undefined reference to `cv::fastFree(void*)'
CMakeFiles\opencv.dir/objects.a(opencv.cpp.obj): In function `cv::Mat::release()':
D:/mingw-build-3.4.11/install/include/opencv2/core/mat.inl.hpp:898: undefined reference to `cv::Mat::deallocate()'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [CMakeFiles\opencv.dir\build.make:91: opencv.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:75: CMakeFiles/opencv.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:82: CMakeFiles/opencv.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:117: opencv] Error 2
Actually no error founded in code check. Moreover, I can find the imread source code through click function with CTRL button pressed.
After building OpenCV with MinGW-w64 I usually do this:
INSTALLPREFIX=installation_path_supplied_as_CMAKE_INSTALL_PREFIX
cp -f build/unix-install/*.pc $INSTALLPREFIX/lib/pkgconfig/
mkdir -p $INSTALLPREFIX/share/OpenCV
mv $INSTALLPREFIX/*.cmake $INSTALLPREFIX/share/OpenCV/
That usually helps get OpenCV to get detected.
I am trying to build opencv like this:
wget -nc -O opencv.tar.gz https://github.com/opencv/opencv/archive/4.1.2.tar.gz
wget -nc -O opencv_contrib.tar.gz https://github.com/opencv/opencv_contrib/archive/4.1.2.tar.gz
echo extracting opencv
tar xzf opencv.tar.gz
tar xzf opencv_contrib.tar.gz
mkdir opencv-build
cd opencv-build
cmake -D CMAKE_BUILD_TYPE=Release \
-D WITH_TBB=ON \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_opencv_bioinspired=OFF \
-D WITH_V4L=ON -D BUILD_opencv_structured_light=OFF \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python3=ON \
-D WITH_CUDA=OFF -D WITH_GSTREAMER=OFF \
-D BUILD_opencv_stereo=OFF \
-D BUILD_opencv_gapi=ON \
-D BUILD_opencv_objdetect=ON \
-D BUILD_opencv_xobjdetect=ON \
-D BUILD_opencv_stitching=OFF \
-D BUILD_opencv_superres=OFF \
-D BUILD_opencv_surface_matching=OFF \
-D BUILD_opencv_text=OFF \
-D BUILD_opencv_face=OFF \
-D BUILD_opencv_xphoto=OFF \
-D BUILD_opencv_calib3d=ON \
-D BUILD_opencv_core=ON \
-D BUILD_opencv_dnn=ON \
-D BUILD_opencv_cvv=OFF \
-D BUILD_opencv_world=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_opencv_python=OFF \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.1.2/modules \
-D BUILD_EXAMPLES=OFF ../opencv-4.1.2
make -j12
It seems to be able to configure itself:
-- Detected processor: x86_64
-- Looking for ccache - not found
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found suitable version "1.2.11", minimum required is "1.2.3")
-- Could NOT find JPEG (missing: JPEG_LIBRARY JPEG_INCLUDE_DIR)
-- libjpeg-turbo: VERSION = 2.0.2, BUILD = opencv-4.1.2-libjpeg-turbo
-- Could NOT find TIFF (missing: TIFF_LIBRARY TIFF_INCLUDE_DIR)
-- Could NOT find Jasper (missing: JASPER_LIBRARIES JASPER_INCLUDE_DIR)
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11")
-- Could NOT find PNG (missing: PNG_LIBRARY PNG_PNG_INCLUDE_DIR)
-- found Intel IPP (ICV version): 2019.0.0 [2019.0.0 Gold]
-- at: /home/stiv2/jsoft-1.0/opencv-build/3rdparty/ippicv/ippicv_lnx/icv
-- found Intel IPP Integration Wrappers sources: 2019.0.0
-- at: /home/stiv2/jsoft-1.0/opencv-build/3rdparty/ippicv/ippicv_lnx/iw
-- Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
-- Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
-- Could NOT find Atlas (missing: Atlas_CBLAS_INCLUDE_DIR Atlas_CLAPACK_INCLUDE_DIR Atlas_CBLAS_LIBRARY Atlas_BLAS_LIBRARY Atlas_LAPACK_LIBRARY)
-- A library with BLAS API not found. Please specify library location.
-- LAPACK requires BLAS
-- A library with LAPACK API not found. Please specify library location.
-- Could NOT find JNI (missing: 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
-- OpenCV Python: during development append to PYTHONPATH: /home/stiv2/jsoft-1.0/opencv-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: Eigen Glog/Gflags
-- Checking for module 'tesseract'
-- No package 'tesseract' found
-- Tesseract: NO
-- Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': /home/stiv2/jsoft-1.0/opencv-4.1.2/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
-- opencv_dnn: filter out cuda4dnn source code
--
-- General configuration for OpenCV 4.1.2 =====================================
-- Version control: 3e33837e-dirty
--
-- Extra modules:
-- Location (extra): /home/stiv2/jsoft-1.0/opencv_contrib-4.1.2/modules
-- Version control (extra): 3e33837e-dirty
--
-- Platform:
-- Timestamp: 2020-05-21T18:21:21Z
-- Host: Linux 5.3.0-51-generic x86_64
-- CMake: 3.10.2
-- CMake generator: Unix Makefiles
-- CMake build tool: /usr/bin/make
-- Configuration: 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 (14 files): + SSSE3 SSE4_1
-- SSE4_2 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2
-- FP16 (0 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
-- AVX (4 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
-- AVX2 (27 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
-- AVX512_SKX (3 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++ Compiler: /usr/bin/c++ (ver 7.5.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 -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -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 -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -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=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 -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=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 -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -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: dl m pthread rt /usr/lib/x86_64-linux-gnu/libOpenGL.so /usr/lib/x86_64-linux-gnu/libGLX.so /usr/lib/x86_64-linux-gnu/libGLU.so
-- 3rdparty dependencies:
--
-- OpenCV modules:
-- To be built: aruco bgsegm calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc line_descriptor ml objdetect optflow phase_unwrapping photo plot python3 quality reg rgbd saliency shape tracking video videoio videostab xfeatures2d ximgproc xobjdetect
-- Disabled: bioinspired cvv face stereo stitching structured_light superres surface_matching text world xphoto
-- Disabled by dependency: -
-- Unavailable: cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev freetype hdf java js matlab ovis python2 sfm ts viz
-- Applications: apps
-- Documentation: NO
-- Non-free algorithms: NO
--
-- GUI:
-- QT: YES (ver 5.9.5)
-- QT OpenGL support: YES (Qt5::OpenGL 5.9.5)
-- GTK+: NO
-- OpenGL support: YES (/usr/lib/x86_64-linux-gnu/libOpenGL.so /usr/lib/x86_64-linux-gnu/libGLX.so /usr/lib/x86_64-linux-gnu/libGLU.so)
-- VTK support: NO
--
-- Media I/O:
-- ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
-- JPEG: libjpeg-turbo (ver 2.0.2-62)
-- WEBP: build (ver encoder: 0x020e)
-- PNG: build (ver 1.6.37)
-- TIFF: build (ver 42 - 4.0.10)
-- JPEG 2000: build (ver 1.900.1)
-- OpenEXR: build (ver 2.3.0)
-- HDR: YES
-- SUNRASTER: YES
-- PXM: YES
-- PFM: YES
--
-- Video I/O:
-- DC1394: YES (2.2.5)
-- FFMPEG: YES
-- avcodec: YES (58.71.100)
-- avformat: YES (58.38.101)
-- avutil: YES (56.41.100)
-- swscale: YES (5.6.100)
-- avresample: YES (3.7.0)
-- v4l/v4l2: YES (linux/videodev2.h)
--
-- Parallel framework: pthreads
--
-- Trace: YES (with Intel ITT)
--
-- Other third-party libraries:
-- Intel IPP: 2019.0.0 Gold [2019.0.0]
-- at: /home/stiv2/jsoft-1.0/opencv-build/3rdparty/ippicv/ippicv_lnx/icv
-- Intel IPP IW: sources (2019.0.0)
-- at: /home/stiv2/jsoft-1.0/opencv-build/3rdparty/ippicv/ippicv_lnx/iw
-- Lapack: NO
-- Eigen: NO
-- Custom HAL: NO
-- Protobuf: build (3.5.1)
--
-- OpenCL: YES (no extra features)
-- Include path: /home/stiv2/jsoft-1.0/opencv-4.1.2/3rdparty/include/opencl/1.2
-- Link libraries: Dynamic load
--
-- Python 3:
-- Interpreter: /usr/bin/python3 (ver 3.6.9)
-- Libraries: /usr/lib/x86_64-linux-gnu/libpython3.6m.so (ver 3.6.9)
-- numpy: /home/stiv2/.local/lib/python3.6/site-packages/numpy/core/include (ver 1.18.1)
-- install path: lib/python3.6/dist-packages/cv2/python-3.6
--
-- Python (for build): /usr/bin/python2.7
--
-- Java:
-- ant: NO
-- JNI: NO
-- Java wrappers: NO
-- Java tests: NO
--
-- Install to: /usr/local
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: /home/stiv2/jsoft-1.0/opencv-build
but when I make it, I suddenly get this:
[ 78%] Linking CXX shared library ../../lib/libopencv_videoio.so
/usr/bin/ld: /usr/local/lib/libavcodec.a(vc1dsp_mmx.o): relocation R_X86_64_PC32 against symbol `ff_pw_9' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
modules/videoio/CMakeFiles/opencv_videoio.dir/build.make:415: recipe for target 'lib/libopencv_videoio.so.4.1.2' failed
make[2]: *** [lib/libopencv_videoio.so.4.1.2] Error 1
CMakeFiles/Makefile2:3689: recipe for target 'modules/videoio/CMakeFiles/opencv_videoio.dir/all' failed
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
what is this and how can I fix it?
I would like to link opencv statically in my c++ program so user does not have to download opencv themselves.
I have tried everything on internet to try to use opencv static library in my c++ program but it is not working.
I have compiled the opencv static library with -DBUILD_SHARED_LIBS=OFF to generate opencv lib files in /usr/local/lib. All of the files has .a extension. I moved these files to a folder in my program and linked it with eclipse with ("${workspace_loc:/${ProjName}/opencv lib}")
I have included -ljpeg -lpng -ltiff -lzlib -lpthread -lrt -ldl -lz -lm
I have put -static flag
I tried to link /usr/local/include/opencv and /usr/local/bin instead
The error message shown a bunch of code like
...
sum.cpp:(.text._ZN2cv3sumERKNS_11_InputArrayE+0xb19): undefined reference to `ippicviSum_16s_C4R'
...
and
/home/vivian/cuda-workspace/AutoVideoAnalyze_v4/opencv lib/libdl.a(dlopen.o): In function dlopen':
(.text+0x5): undefined reference to__dlopen'
/home/vivian/cuda-workspace/AutoVideoAnalyze_v4/opencv lib/libdl.a(dlclose.o): In function dlclose':
(.text+0x1): undefined reference to__dlclose'
/home/vivian/cuda-workspace/AutoVideoAnalyze_v4/opencv lib/libdl.a(dlsym.o): In function dlsym':
(.text+0x5): undefined reference to__dlsym'
collect2: error: ld returned 1 exit status
make: *** [AutoVideoAnalyze_v4] Error 1
I have tried many combination and different ways on google but nothing works. Have anyone actually linked opencv statically on their c++ program? Can you share your work please?
Finally linked opencv statically i eclipse! I used Opencv Cuda, IPP, ffmpeg and many other libraries so there are more libraries to include!
gcc c++ linker: Libraries(-l):
opencv_cudabgsegm, opencv_cudaobjdetect ,opencv_cudastereo, opencv_stitching, opencv_cudafeatures2d, opencv_superres, opencv_cudacodec, opencv_videostab, opencv_cudaoptflow, opencv_cudalegacy, opencv_cudawarping, opencv_aruco, opencv_bgsegm, opencv_bioinspired, opencv_ccalib, opencv_cvv, opencv_dnn_objdetect, opencv_dpm, opencv_face, opencv_photo, opencv_cudaimgproc, opencv_cudafilters, opencv_freetype, opencv_fuzzy, opencv_hdf, opencv_hfs, opencv_img_hash, opencv_line_descriptor, opencv_optflow, opencv_reg, opencv_rgbd, opencv_saliency, opencv_stereo, opencv_structured_light, opencv_phase_unwrapping, opencv_surface_matching, opencv_tracking, opencv_datasets, opencv_text, opencv_dnn, opencv_plot, opencv_xfeatures2d, opencv_shape, opencv_video, opencv_ml, opencv_cudaarithm, opencv_ximgproc, opencv_calib3d, opencv_features2d, opencv_highgui, opencv_videoio, opencv_flann, opencv_xobjdetect, opencv_imgcodecs, opencv_objdetect, opencv_xphoto, opencv_imgproc, opencv_core, opencv_cudev, libprotobuf, GLU, GL, gstpbutils-1.0, gstriff-1.0, gstapp-1.0, gstvideo-1.0, gstbase-1.0, gstreamer-1.0, gobject-2.0, glib-2.0, avcodec, avformat, swscale, avutil, avfilter, swresample, avresample, avdevice, postproc, m, z, x264, lzma, rt, dc1394, tbb, gphoto2_port, gphoto2, xine, jpeg, webp, png, tiff, jasper, Imath, hdf5, lept, sz, IlmImf, cudart, nppc, nppial, nppicc, nppicom, nppidei, nppif, nppig, nppim, nppist, nppisu, nppitc, npps, cublas, cufft, ippiw, ippicv, ittnotify, dl, pthread
Library search path (-L):
/usr/include, /usr/lib/x86_64-linux-gnu, /usr/lib/x86_64-linux-gnu/hdf5/serial/, /usr/local/share/OpenCV/3rdparty/lib, /usr/local/cuda-9.2/lib64, /usr/local/lib
If you want to know what library do you need to include, you can look at the General configuration that looks like the script below (*appear when you are building opencv) and include every library in the script into the program that you want to link opencv statically.
General configuration for OpenCV 3.4.2 =====================================
-- Version control: 3.4.2
--
-- Extra modules:
-- Location (extra): /home/vivian/Downloads/opencv_contrib/modules
-- Version control (extra): 3.4.2
--
-- Platform:
-- Timestamp: 2019-01-17T01:23:08Z
-- Host: Linux 4.15.0-43-generic x86_64
-- CMake: 3.10.2
-- CMake generator: Unix Makefiles
-- CMake build tool: /usr/bin/make
-- Configuration: 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 (3 files): + SSSE3 SSE4_1
-- SSE4_2 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2
-- FP16 (2 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
-- AVX (5 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
-- AVX2 (9 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
-- AVX512_SKX (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_SKX
--
-- C/C++:
-- Built as dynamic libs?: NO
-- C++11: YES
-- C++ Compiler: /usr/bin/c++ (ver 7.3.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-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections -msse -msse2 -msse3 -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-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections -msse -msse2 -msse3 -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=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-narrowing -Wno-comment -Wimplicit-fallthrough=3 -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=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 -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wimplicit-fallthrough=3 -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
-- Linker flags (Release):
-- Linker flags (Debug):
-- ccache: NO
-- Precompiled headers: NO
-- Extra dependencies: /usr/lib/x86_64-linux-gnu/libtbb.so /usr/lib/x86_64-linux-gnu/libcuda.so /usr/lib/x86_64-linux-gnu/libnvcuvid.so Qt5::Test Qt5::Concurrent Qt5::OpenGL /usr/lib/x86_64-linux-gnu/libwebp.so /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/x86_64-linux-gnu/libtiff.so /usr/lib/x86_64-linux-gnu/libjasper.so /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so gstbase-1.0 gstreamer-1.0 gobject-2.0 glib-2.0 gstvideo-1.0 gstapp-1.0 gstriff-1.0 gstpbutils-1.0 dc1394 xine avformat z avcodec lzma swresample swscale avutil avresample gphoto2 gphoto2_port Qt5::Core Qt5::Gui Qt5::Widgets freetype harfbuzz /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so /usr/lib/x86_64-linux-gnu/libpthread.so /usr/lib/x86_64-linux-gnu/libsz.so /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/x86_64-linux-gnu/libdl.so /usr/lib/x86_64-linux-gnu/libm.so tesseract lept dl m pthread rt /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so cudart nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/local/cuda-9.2/lib64
-- 3rdparty dependencies: ittnotify libprotobuf ippiw ippicv
--
-- 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 dpm face features2d flann freetype fuzzy hdf hfs highgui img_hash imgcodecs imgproc java java_bindings_generator line_descriptor ml objdetect optflow phase_unwrapping photo plot python2 python3 python_bindings_generator reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
-- Disabled: js world
-- Disabled by dependency: -
-- Unavailable: cnn_3dobj matlab ovis sfm viz
-- Applications: tests perf_tests apps
-- Documentation: NO
-- Non-free algorithms: NO
--
-- GUI:
-- QT: YES (ver 5.9.5)
-- QT OpenGL support: YES (Qt5::OpenGL 5.9.5)
-- GTK+: NO
-- OpenGL support: YES (/usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so)
-- VTK support: NO
--
-- Media I/O:
-- ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
-- JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
-- WEBP: /usr/lib/x86_64-linux-gnu/libwebp.so (ver encoder: 0x020e)
-- PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.34)
-- TIFF: /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.0.9)
-- JPEG 2000: /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
-- OpenEXR: /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 2.2.0)
-- HDR: YES
-- SUNRASTER: YES
-- PXM: YES
--
-- Video I/O:
-- DC1394: YES (ver 2.2.5)
-- FFMPEG: YES
-- avcodec: YES (ver 58.25.100)
-- avformat: YES (ver 58.17.103)
-- avutil: YES (ver 56.19.100)
-- swscale: YES (ver 5.2.100)
-- avresample: YES (ver 3.7.0)
-- GStreamer:
-- base: YES (ver 1.14.1)
-- video: YES (ver 1.14.1)
-- app: YES (ver 1.14.1)
-- riff: YES (ver 1.14.1)
-- pbutils: YES (ver 1.14.1)
-- libv4l/libv4l2: NO
-- v4l/v4l2: linux/videodev2.h
-- Xine: YES (ver 1.2.8)
-- gPhoto2: YES
--
-- Parallel framework: TBB (ver 2017.0 interface 9107)
--
-- Trace: YES (with Intel ITT)
--
-- Other third-party libraries:
-- Intel IPP: 2017.0.3 [2017.0.3]
-- at: /home/vivian/Downloads/opencv/build/3rdparty/ippicv/ippicv_lnx
-- Intel IPP IW: sources (2017.0.3)
-- at: /home/vivian/Downloads/opencv/build/3rdparty/ippicv/ippiw_lnx
-- Lapack: NO
-- Eigen: YES (ver 3.3.4)
-- Custom HAL: NO
-- Protobuf: build (3.5.1)
--
-- NVIDIA CUDA: YES (ver 9.2, CUFFT CUBLAS NVCUVID FAST_MATH)
-- NVIDIA GPU arch: 61
-- NVIDIA PTX archs:
--
-- OpenCL: YES (no extra features)
-- Include path: /home/vivian/Downloads/opencv/3rdparty/include/opencl/1.2
-- Link libraries: Dynamic load
--
-- Python 2:
-- Interpreter: /usr/bin/python2.7 (ver 2.7.15)
-- Libraries: /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.15rc1)
-- numpy: /home/vivian/.local/lib/python2.7/site-packages/numpy/core/include (ver 1.15.2)
-- packages path: lib/python2.7/dist-packages
--
-- Python 3:
-- Interpreter: /usr/bin/python3 (ver 3.6.7)
-- Libraries: /usr/lib/x86_64-linux-gnu/libpython3.6m.so (ver 3.6.7)
-- numpy: /home/vivian/.local/lib/python3.6/site-packages/numpy/core/include (ver 1.15.4)
-- packages path: lib/python3.6/dist-packages
--
-- Python (for build): /usr/bin/python2.7
--
-- Java:
-- ant: /usr/bin/ant (ver 1.10.3)
-- 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: YES
--
-- Matlab: NO
--
-- Install to: /usr/local
I am not sure why I cannot read an image by using imread function and the details about my code are as the following.
#include <iostream>
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/core.hpp"
int main(int argc, const char * argv[])
{
cv::Mat scrImage = cv::imread("/Users/zsk/Downloads/zsk.JPEG", CV_LOAD_IMAGE_COLOR);
if(scrImage.empty())
{
std::cout << "something wrong" << std::endl;
return -1;
}
cv::Mat scrGray;
cv::cvtColor(scrImage, scrGray, CV_RGB2GRAY);
cv::imshow("scrGray", scrGray);
cv::Mat blurDstImage;
blur(scrGray, blurDstImage, cv::Size(5, 5), cv::Point(-1, 1));
cv::imshow("blurDstImage", blurDstImage);
cv::imwrite("/Users/zsk/Downloads/blurgirl.jpg", blurDstImage);
cv::waitKey(0);
return 0;
}
General configuration for OpenCV 3.4.3 =====================================
Version control: unknown
Extra modules:
Location (extra): /tmp/opencv-20181001-83194-s618mv/opencv-3.4.3/opencv_contrib/modules
Version control (extra): unknown
Platform:
Timestamp: 2018-10-01T12:58:23Z
Host: Darwin 18.0.0 x86_64
CMake: 3.12.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
requested: DETECT
disabled: SSE4_1 SSE4_2 AVX AVX2
Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
SSE4_1 (3 files): + SSE4_1
SSE4_2 (1 files): + SSE4_1 POPCNT SSE4_2
FP16 (1 files): + SSE4_1 POPCNT SSE4_2 FP16 AVX
AVX (5 files): + SSE4_1 POPCNT SSE4_2 AVX
AVX2 (9 files): + SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
AVX512_SKX (1 files): + SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_SKX
C/C++:
Built as dynamic libs?: YES
C++11: YES
C++ Compiler: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang++ (ver 10.0.0.10001145)
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 -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-narrowing -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 -msse -msse2 -msse3 -mssse3 -fvisibility=hidden -fvisibility-inlines-hidden -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 -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-narrowing -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 -msse -msse2 -msse3 -mssse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
C Compiler: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang
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 -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-narrowing -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 -msse -msse2 -msse3 -mssse3 -fvisibility=hidden -fvisibility-inlines-hidden -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 -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-narrowing -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 -msse -msse2 -msse3 -mssse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release):
Linker flags (Debug):
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 fuzzy hfs highgui img_hash imgcodecs imgproc java_bindings_generator line_descriptor ml objdetect optflow phase_unwrapping photo plot python2 python3 python_bindings_generator reg rgbd saliency shape stereo stitching structured_light superres surface_matching tracking video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
Disabled: js text world
Disabled by dependency: -
Unavailable: cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype hdf java matlab ovis sfm 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 1.5.3-62)
WEBP: build (ver encoder: 0x020e)
PNG: /usr/local/lib/libpng.dylib (ver 1.6.35)
TIFF: /usr/local/lib/libtiff.dylib (ver 42 / 4.0.9)
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.2.0)
HDR: YES
SUNRASTER: YES
PXM: YES
Video I/O:
FFMPEG: YES
avcodec: YES (ver 58.18.100)
avformat: YES (ver 58.12.100)
avutil: YES (ver 56.14.100)
swscale: YES (ver 5.1.100)
avresample: YES (ver 4.0.0)
AVFoundation: YES
Parallel framework: TBB (ver 2018.0 interface 10005)
Trace: YES (with Intel ITT)
Other third-party libraries:
Intel IPP: 2017.0.3 [2017.0.3]
at: /tmp/opencv-20181001-83194-s618mv/opencv-3.4.3/build/3rdparty/ippicv/ippicv_mac
Intel IPP IW: sources (2017.0.3)
at: /tmp/opencv-20181001-83194-s618mv/opencv-3.4.3/build/3rdparty/ippicv/ippiw_mac
Lapack: YES (/System/Library/Frameworks/Accelerate.framework /System/Library/Frameworks/Accelerate.framework)
Eigen: YES (ver 3.3.5)
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.15)
Libraries: /usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib (ver 2.7.15)
numpy: /usr/local/lib/python2.7/site-packages/numpy/core/include (ver 1.15.1)
packages path: lib/python2.7/site-packages
Python 3:
Interpreter: /usr/local/opt/python/bin/python3 (ver 3.7)
Libraries: /usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin/libpython3.7.dylib (ver 3.7.0)
numpy: /usr/local/lib/python3.7/site-packages/numpy/core/include (ver 1.15.1)
packages path: lib/python3.7/site-packages
Python (for build): /usr/local/opt/python#2/bin/python
Java:
ant: NO
JNI: /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/include /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/include/darwin /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/include
Java wrappers: NO
Java tests: NO
Matlab: NO
Install to: /usr/local/Cellar/opencv/3.4.3
Finally, I find that the problem is that Opencv is header only which needs to special compile.
I'm testing the class cv::ParallelLoopBody for image processing code.
I first started implementing the normalization, where I've to divide all the pixels with certain values for each channel, which is an easy nice parallelized code.
However, when testing it, I don't see any difference.
Am I doing something wrong here?
This is my class:
class Parallel_process : public cv::ParallelLoopBody
{
private:
cv::Mat img; //my image to normalize
std::vector<int> A;
int diff;
public:
Parallel_process(cv::Mat inputImage, std::vector<int> AA, int diffVal)
: img(inputImage), A(AA), diff(diffVal){}
virtual void operator()(const cv::Range& range) const
{
for(int i = range.start; i < range.end; i++)
{
//in is a patch of my original image
cv::Mat in(img, cv::Rect(0, (img.rows/diff)*i, img.cols, img.rows/diff));
std::vector<int> AAA (A);
in.forEach<cv::Vec3f>
(
[&AAA](cv::Vec3f &pixel, const int* po) -> void
{
pixel[0]/=AAA[0];
pixel[1]/=AAA[1];
pixel[2]/=AAA[2];
}
);
}
}
};
and in main() function I'm calling my operator like so:
cv::parallel_for_(cv::Range(0, 91), Parallel_process(img, AA, 91)); //my image is 1288*728 size so 728/91=8
EDIT
This my OpenCV configuation:
General configuration for OpenCV 3.3.1 =====================================
Version control: unknown
Extra modules:
Location (extra): /home/jrsros/opencv_contrib-3.3.1/modules
Version control (extra): unknown
Platform:
Timestamp: 2017-12-14T13:05:47Z
Host: Linux 4.10.0-40-generic x86_64
CMake: 3.5.1
CMake generator: Unix Makefiles
CMake build tool: /usr/bin/make
Configuration: Release
CPU/HW features:
Baseline: SSE SSE2 SSE3
requested: SSE3
Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2
requested: SSE4_1 SSE4_2 AVX FP16 AVX2
SSE4_1 (3 files): + SSSE3 SSE4_1
SSE4_2 (1 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 (8 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
C/C++:
Built as dynamic libs?: YES
C++11: YES
C++ Compiler: /usr/bin/c++ (ver 7.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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wno-implicit-fallthrough -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -g -O0 -DDEBUG -D_DEBUG
C Compiler: /usr/bin/gcc-5
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 -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -msse -msse2 -msse3 -fvisibility=hidden -fopenmp -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 -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffast-math -ffunction-sections -msse -msse2 -msse3 -fvisibility=hidden -fopenmp -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release):
Linker flags (Debug):
ccache: NO
Precompiled headers: NO
Extra dependencies: dl m pthread rt /usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libtbb.so cudart nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/local/cuda-8.0/lib64
3rdparty dependencies:
OpenCV modules:
To be built: cudev core cudaarithm flann hdf imgproc ml objdetect phase_unwrapping plot reg surface_matching video viz xphoto bgsegm cudabgsegm cudafilters cudaimgproc cudawarping dnn face freetype fuzzy img_hash imgcodecs photo shape videoio xobjdetect cudacodec highgui bioinspired dpm features2d line_descriptor saliency text calib3d ccalib cudafeatures2d cudalegacy cudaobjdetect cudaoptflow cudastereo datasets rgbd stereo structured_light superres tracking videostab xfeatures2d ximgproc aruco optflow stitching python2
Disabled: js world contrib_world
Disabled by dependency: -
Unavailable: java python3 ts cnn_3dobj cvv dnn_modern matlab sfm
GUI:
QT: NO
GTK+ 2.x: YES (ver 2.24.30)
GThread : YES (ver 2.48.2)
GtkGlExt: YES (ver 1.2.0)
OpenGL support: YES (/usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so)
VTK support: YES (ver 6.2.0)
Media I/O:
ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
WEBP: /usr/lib/x86_64-linux-gnu/libwebp.so (ver encoder: 0x0202)
PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.54)
TIFF: /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.6)
JPEG 2000: /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
OpenEXR: build (ver 1.7.1)
GDAL: NO
GDCM: NO
Video I/O:
DC1394 1.x: NO
DC1394 2.x: NO
FFMPEG: YES
avcodec: YES (ver 56.60.100)
avformat: YES (ver 56.40.101)
avutil: YES (ver 54.31.100)
swscale: YES (ver 3.1.101)
avresample: NO
GStreamer:
base: YES (ver 1.8.3)
video: YES (ver 1.8.3)
app: YES (ver 1.8.3)
riff: YES (ver 1.8.3)
pbutils: YES (ver 1.8.3)
OpenNI: NO
OpenNI PrimeSensor Modules: NO
OpenNI2: NO
PvAPI: NO
GigEVisionSDK: NO
Aravis SDK: NO
UniCap: NO
UniCap ucil: NO
V4L/V4L2: NO/YES
XIMEA: NO
Xine: NO
Intel Media SDK: NO
gPhoto2: NO
Parallel framework: TBB (ver 4.4 interface 9002)
Trace: YES (with Intel ITT)
Other third-party libraries:
Use Intel IPP: 2017.0.3 [2017.0.3]
at: /home/jrsros/opencv-3.3.1/build/3rdparty/ippicv/ippicv_lnx
Use Intel IPP IW: sources (2017.0.3)
at: /home/jrsros/opencv-3.3.1/build/3rdparty/ippicv/ippiw_lnx
Use VA: NO
Use Intel VA-API/OpenCL: NO
Use Lapack: NO
Use Eigen: YES (ver 3.2.92)
Use Cuda: YES (ver 8.0)
Use OpenCL: YES
Use OpenVX: NO
Use custom HAL: NO
NVIDIA CUDA
Use CUFFT: YES
Use CUBLAS: YES
USE NVCUVID: NO
NVIDIA GPU arch: 20 30 35 37 50 52 60 61
NVIDIA PTX archs:
Use fast math: YES
OpenCL: <Dynamic loading of OpenCL library>
Include path: /home/jrsros/opencv-3.3.1/3rdparty/include/opencl/1.2
Use AMDFFT: NO
Use AMDBLAS: NO
Python 2:
Interpreter: /usr/bin/python2.7 (ver 2.7.12)
Libraries: /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.12)
numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.11.0)
packages path: lib/python2.7/dist-packages
Python 3:
Interpreter: /usr/bin/python3 (ver 3.5.2)
Python (for build): /usr/bin/python2.7
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Matlab:
mex: /usr/local/MATLAB/R2017b/bin/mex
Compiler/generator: Not working (bindings will not be generated)
Documentation:
Doxygen: NO
Tests and samples:
Tests: NO
Performance tests: NO
C/C++ Examples: NO
Install path: /usr/local
cvconfig.h is in: /home/jrsros/opencv-3.3.1/build
-----------------------------------------------------------------
An example of code I'm using to test my parallelism:
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/core/utility.hpp>
#include <iostream>
#include <sys/time.h>
class Parallel_process : public cv::ParallelLoopBody
{
private:
cv::Mat img;
std::vector<int> A;
int diff;
public:
Parallel_process(cv::Mat inputImgage, std::vector<int> AA, int diffVal)
: img(inputImgage), A(AA), diff(diffVal){}
virtual void operator()(const cv::Range& range) const
{
for(int i = range.start; i < range.end; i++)
{
cv::Mat in(img, cv::Rect(0, (img.rows/diff)*i, img.cols, img.rows/diff));
std::vector<int> AAA (A);
in.forEach<cv::Vec3f>
(
[&AAA](cv::Vec3f &pixel, const int* po) -> void
{
pixel[0]/=AAA[0];
pixel[1]/=AAA[1];
pixel[2]/=AAA[2];
}
);
}
}
};
int main(int argc, char* argv[])
{
cv::Mat src=cv::imread(argv[1]);
std::vector<std::vector<int> > AA;
//compute AA here
double timeStart=tic(), timeEnd=0;
//Normalize the image /AA
cv::parallel_for_(cv::Range(0, 91), Parallel_process(src, AA, 91));
timeEnd = tic() - timeStart;
std::cout << "ALL " <<1/timeEnd << std::endl<< std::endl; //FPS
return 0;
}
I'm compiling my code on linux ubuntu Core i7-2630QM 2Ghz * 8 threads (4 cores):
g++ -std=c++1z -Wall -Weffc++ -Ofast -march=native test4.cpp -o test4 `pkg-config --cflags --libs opencv`
EDIT2
In htop I see that it is using all the threads at the end
1 2 3 4 5 6 7 8
Variant 1
threads,mean(us),min(us),max(us)
1,18798.2,18106,22780
2,9762.84,9427,10397
3,6813.55,6765,9296
4,5317.75,5088,7433
5,5067.11,4931,7552
6,4925.41,4780,9473
7,4797.74,4641,9492
8,4798.18,4504,27244
1 2 3 4 5 6 7 8
Variant 2
threads,mean(us),min(us),max(us)
1,18512.8,17780,20084
2,9788.73,9302,11338
3,6850.47,6671,9765
4,5209.64,5022,8831
5,5052.46,4881,7041
6,6851.99,4762,11422
7,5077.32,4624,9886