opencv_contrib
opencv_contrib copied to clipboard
CMake Error at: xobjdetect/CMakeLists.txt:6 (add_subdirectory) - OpenCV 5.0.0-alpha
Hello,
Trying to build OpenCV using CMake GUI.
Performed the following:
git clone https://github.com/opencv/opencv.git
cd opencv
git fetch --all --tags
git tag
git checkout 5.0.0-alpha
git log -1
git submodule update --init --recursive
I get an error for xobjdetect module during config build process. Here is the tree for the xobjdetect module:
F:\AI_Componets\OpenCV\opencv_contrib\modules\xobjdetect>tree
Folder PATH listing for volume Mangus
Volume serial number is D241-B91C
F:.
├───data
│ ├───haarcascades
│ ├───haarcascades_cuda
│ ├───hogcascades
│ ├───lbpcascades
│ └───vec_files
├───doc
│ └───pics
├───include
│ └───opencv2
│ └───xobjdetect
├───misc
│ ├───java
│ │ └───test
│ └───python
│ └───test
├───perf
│ └───opencl
├───samples
│ ├───gpu
│ ├───java
│ │ └───tutorial_code
│ │ └───objectDetection
│ │ └───cascade_classifier
│ └───python
│ └───tutorial_code
│ └───objectDetection
│ └───cascade_classifier
├───src
│ └───opencl
├───test
│ └───opencl
├───tools
│ ├───annotation
│ ├───visualisation
│ └───waldboost_detector
└───tutorials
├───cascade_classifier
│ └───images
├───js_tutorials
│ ├───js_assets
│ └───js_objdetect
│ └───js_face_detection
└───traincascade
└───images
Here is the CMake error:
Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
Detected processor: AMD64
Could NOT find AVIF (missing: AVIF_LIBRARY AVIF_INCLUDE_DIR)
libjpeg-turbo: VERSION = 3.0.3, BUILD = opencv-5.0.0alpha-libjpeg-turbo
CMAKE_ASM_NASM_COMPILER = F:/Program Files/NASM/nasm.exe
CMAKE_ASM_NASM_OBJECT_FORMAT = win64
CMAKE_ASM_NASM_FLAGS = -DWIN64 -D__x86_64__
SIMD extensions: x86_64 (WITH_SIMD = 1)
Could NOT find OpenJPEG (minimal suitable version: 2.0, recommended version >= 2.3.1). OpenJPEG will be built from sources
OpenJPEG: VERSION = 2.5.0, BUILD = opencv-5.0.0alpha-openjp2-2.5.0
OpenJPEG libraries will be built from sources: libopenjp2 (version "2.5.0")
CMake Warning (dev) at cmake/OpenCVFindOpenEXR.cmake:13 (find_package):
Policy CMP0144 is not set: find_package uses upper-case <PACKAGENAME>_ROOT
variables. Run "cmake --help-policy CMP0144" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
CMake variable OPENEXR_ROOT is set to:
C:/Deploy
For compatibility, find_package is ignoring the variable, but code in a
.cmake module might still use it.
Call Stack (most recent call first):
cmake/OpenCVFindLibsGrfmt.cmake:324 (include)
CMakeLists.txt:727 (include)
This warning is for project developers. Use -Wno-dev to suppress it.
found Intel IPP (ICV version): 2021.12.0 [2021.12.0]
at: F:/AI_Componets/OpenCV/build/3rdparty/ippicv/ippicv_win/icv
found Intel IPP Integration Wrappers sources: 2021.12.0
at: F:/AI_Componets/OpenCV/build/3rdparty/ippicv/ippicv_win/iw
Found NVCUVID: F:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6/lib/x64/nvcuvid.lib
Found NVCUVENC: F:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6/lib/x64/nvencodeapi.lib
CUDA detected: 12.6
CUDA: Using CUDA_ARCH_BIN=8.6
CUDA: NVCC target flags -gencode;arch=compute_86,code=sm_86;-D_FORCE_INLINES;-gencode;arch=compute_86,code=compute_86
CUDA: MSVS generator is detected. Disabling CMake re-run checks (CMAKE_SUPPRESS_REGENERATION=ON). You need to run CMake manually if updates are required.
Module opencv_alphamat disabled because the following dependencies are not found: Eigen
freetype2: NO
harfbuzz: NO
Julia not found. Not compiling Julia Bindings.
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
Tesseract: NO
Processing WORLD modules...
module opencv_cudev...
module opencv_core...
Excluding from source files list: <BUILD>/modules/world/test/test_intrin256.lasx.cpp
module opencv_cudaarithm...
module opencv_flann...
module opencv_imgproc...
Unicode font has been downloaded successfully.
module opencv_intensity_transform...
module opencv_ml...
module opencv_phase_unwrapping...
module opencv_plot...
module opencv_quality...
module opencv_reg...
module opencv_signal...
module opencv_surface_matching...
module opencv_cudafilters...
module opencv_cudaimgproc...
module opencv_cudawarping...
module opencv_dnn...
Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': F:/AI_Componets/OpenCV/opencv/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
module opencv_dnn_superres...
module opencv_features...
module opencv_fuzzy...
module opencv_hfs...
module opencv_imgcodecs...
imgcodecs: OpenEXR codec is disabled in runtime. Details: https://github.com/opencv/opencv/issues/21326
module opencv_line_descriptor...
module opencv_photo...
module opencv_saliency...
module opencv_text...
module opencv_videoio...
module opencv_xobjdetect...
CMake Error at F:/AI_Componets/OpenCV/opencv_contrib/modules/xobjdetect/CMakeLists.txt:6 (add_subdirectory):
add_subdirectory given source "data" which is not an existing directory.
Call Stack (most recent call first):
modules/world/CMakeLists.txt:13 (include)
modules/world/CMakeLists.txt:50 (include_one_module)
module opencv_xphoto...
module opencv_3d...
3d: Eigen support is disabled. Eigen is Required for Posegraph optimization
module opencv_cudacodec...
module opencv_cudafeatures2d...
module opencv_datasets...
module opencv_face...
module opencv_highgui...
highgui: using builtin backend: WIN32UI
module opencv_mcc...
module opencv_objdetect...
module opencv_rapid...
module opencv_rgbd...
module opencv_shape...
module opencv_stereo...
module opencv_video...
module opencv_wechat_qrcode...
module opencv_xfeatures2d...
module opencv_ximgproc...
module opencv_bgsegm...
module opencv_bioinspired...
module opencv_calib...
module opencv_ccalib...
module opencv_cudabgsegm...
module opencv_cudalegacy...
module opencv_cudaobjdetect...
module opencv_cudastereo...
module opencv_dnn_objdetect...
module opencv_dpm...
module opencv_gapi...
module opencv_optflow...
module opencv_stitching...
module opencv_structured_light...
module opencv_tracking...
module opencv_xstereo...
module opencv_cudaoptflow...
Building with NVIDIA Optical Flow API 2.0
module opencv_superres...
module opencv_videostab...
Processing WORLD modules... DONE
Excluding from source files list: modules/imgproc/src/imgwarp.lasx.cpp
Excluding from source files list: modules/imgproc/src/resize.lasx.cpp
Excluding from source files list: <BUILD>/modules/world/layers/layers_common.rvv.cpp
Excluding from source files list: <BUILD>/modules/world/layers/layers_common.lasx.cpp
Excluding from source files list: <BUILD>/modules/world/int8layers/layers_common.rvv.cpp
Excluding from source files list: <BUILD>/modules/world/int8layers/layers_common.lasx.cpp
Excluding from source files list: <BUILD>/modules/world/layers/cpu_kernels/conv_block.neon.cpp
Excluding from source files list: <BUILD>/modules/world/layers/cpu_kernels/conv_block.neon_fp16.cpp
Excluding from source files list: <BUILD>/modules/world/layers/cpu_kernels/conv_depthwise.rvv.cpp
Excluding from source files list: <BUILD>/modules/world/layers/cpu_kernels/conv_depthwise.lasx.cpp
Excluding from source files list: <BUILD>/modules/world/layers/cpu_kernels/fast_gemm_kernels.neon.cpp
Excluding from source files list: <BUILD>/modules/world/layers/cpu_kernels/fast_gemm_kernels.lasx.cpp
Use autogenerated whitelist F:/AI_Componets/OpenCV/build/modules/js_bindings_generator/whitelist.json
Found 'misc' Python modules from F:/AI_Componets/OpenCV/opencv/modules/python/package/extra_modules
Found 'mat_wrapper;utils' Python modules from F:/AI_Componets/OpenCV/opencv/modules/core/misc/python/package
Found 'gapi' Python modules from F:/AI_Componets/OpenCV/opencv_contrib/modules/gapi/misc/python/package
Found 'misc' Python modules from F:/AI_Componets/OpenCV/opencv/modules/python/package/extra_modules
Found 'mat_wrapper;utils' Python modules from F:/AI_Componets/OpenCV/opencv/modules/core/misc/python/package
Found 'gapi' Python modules from F:/AI_Componets/OpenCV/opencv_contrib/modules/gapi/misc/python/package
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
CMake Warning at cmake/OpenCVGenSetupVars.cmake:54 (message):
CONFIGURATION IS NOT SUPPORTED: validate setupvars script in install
directory
Call Stack (most recent call first):
CMakeLists.txt:1071 (include)
General configuration for OpenCV 5.0.0alpha =====================================
Version control: 5.0.0-alpha
Extra modules:
Location (extra): F:/AI_Componets/OpenCV/opencv_contrib/modules
Version control (extra): 5.0.0-alpha
Platform:
Timestamp: 2024-12-31T01:27:24Z
Host: Windows 10.0.19045 AMD64
CMake: 3.30.2
CMake generator: Visual Studio 17 2022
CMake build tool: F:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe
MSVC: 1942
Configuration: Release
Algorithm Hint: ALGO_HINT_ACCURATE
CPU/HW features:
Baseline: SSE SSE2 SSE3
requested: SSE3
Dispatched code generation: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
SSE4_1 (20 files): + SSSE3 SSE4_1
SSE4_2 (2 files): + SSSE3 SSE4_1 POPCNT SSE4_2
AVX (9 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
FP16 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX FP16
AVX2 (41 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX FP16 AVX2 FMA3
AVX512_SKX (8 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX FP16 AVX2 FMA3 AVX_512F AVX512_COMMON AVX512_SKX
C/C++:
Built as dynamic libs?: YES
C++ standard: 17
C++ Compiler: F:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64/cl.exe (ver 19.42.34435.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:fast /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /wd4819 /MP -openmp /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:fast /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /wd4819 /MP -openmp /Zi /Ob0 /Od /RTC1
C Compiler: F:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.42.34433/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:fast /MP -openmp /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:fast /MP -openmp /Zi /Ob0 /Od /RTC1
Linker flags (Release): /machine:x64 /INCREMENTAL:NO
Linker flags (Debug): /machine:x64 /debug /INCREMENTAL
ccache: NO
Precompiled headers: NO
Extra dependencies: cudart_static.lib nppc.lib nppial.lib nppicc.lib nppidei.lib nppif.lib nppig.lib nppim.lib nppist.lib nppisu.lib nppitc.lib npps.lib cublas.lib cudnn.lib cufft.lib -LIBPATH:F:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.6/lib/x64
3rdparty dependencies:
OpenCV modules:
To be built: 3d bgsegm bioinspired calib ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dnn_superres dpm face features flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape signal stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode world xfeatures2d ximgproc xobjdetect xphoto xstereo
Disabled: -
Disabled by dependency: -
Unavailable: alphamat cannops cvv freetype hdf java julia matlab ovis sfm viz
Applications: tests perf_tests apps
Documentation: NO
Non-free algorithms: YES
Windows RT support: NO
GUI:
Win32 UI: YES
OpenGL support: YES (opengl32 glu32)
Built-in Unicode font: YES
Media I/O:
ZLib: build (ver 1.3.1)
JPEG: build-libjpeg-turbo (ver 3.0.3-70)
SIMD Support Request: YES
SIMD Support: YES
WEBP: build (ver encoder: 0x020f)
AVIF: NO
PNG: build (ver 1.6.43)
SIMD Support Request: YES
SIMD Support: YES (Intel SSE)
TIFF: build (ver 42 - 4.6.0)
JPEG 2000: build (ver 2.5.0)
OpenEXR: build (ver 2.3.0)
HDR: YES
SUNRASTER: YES
PXM: YES
PFM: YES
Video I/O:
FFMPEG: YES (prebuilt binaries)
avcodec: YES (61.19.100)
avformat: YES (61.7.100)
avutil: YES (59.39.100)
swscale: YES (8.3.100)
avresample: NO
GStreamer: NO
DirectShow: YES
Media Foundation: YES
DXVA: YES
Parallel framework: OpenMP
Trace: YES (with Intel ITT)
Other third-party libraries:
Intel IPP: 2021.12.0 [2021.12.0]
at: F:/AI_Componets/OpenCV/build/3rdparty/ippicv/ippicv_win/icv
Intel IPP IW: sources (2021.12.0)
at: F:/AI_Componets/OpenCV/build/3rdparty/ippicv/ippicv_win/iw
Lapack: YES (libclapack 3.9.0)
Eigen: NO
Custom HAL: NO
Protobuf: build (3.19.1)
Flatbuffers: builtin/3rdparty (23.5.9)
NVIDIA CUDA: YES (ver 12.6, CUFFT CUBLAS NVCUVID NVCUVENC FAST_MATH)
NVIDIA GPU arch: 86
NVIDIA PTX archs: 86
cuDNN: YES (ver 9.6.0)
OpenCL: YES (SVM NVD3D11)
Include path: F:/AI_Componets/OpenCV/opencv/3rdparty/include/opencl/1.2
Link libraries: Dynamic load
ONNX: YES
Include path: F:/AI_Componets/ONNX/windows_bin/onnxruntime-win-x64-gpu-1.20.1/include
Link libraries: F:/AI_Componets/ONNX/windows_bin/onnxruntime-win-x64-gpu-1.20.1/lib/onnxruntime.lib
Python 3:
Interpreter: C:/Python312/python.exe (ver 3.12.5)
Libraries: C:/Python312/libs/python312.lib (ver 3.12.5)
Limited API: NO
numpy: C:/Users/Rajh/AppData/Roaming/Python/Python312/site-packages/numpy/_core/include (ver 2.2.1)
install path: C:/Python312/Lib/site-packages/cv2/python-3.12
Python (for build): C:/Python312/python.exe
Install to: F:/AI_Componets/OpenCV/build/install
-----------------------------------------------------------------
Configuring incomplete, errors occurred!
What could be issue?
Thanks.
Alright, seems like there was some error in OpenCV core and OpenCV contrib folders, for which there was some mismatch in version contents and wasn't properly downloaded.
So I properly downloaded both the git sources and now seem to get no errors. Here is how I did so:
OpenCV Core:
git clone https://github.com/opencv/opencv.git
cd opencv
git fetch --all --tags
git tag
git checkout 5.0.0-alpha
git log -1
git submodule update --init --recursive
OpenCV Extra Modules:
git clone https://github.com/opencv/opencv_contrib.git
cd opencv_contrib
git fetch --all --tags
git tag
git checkout 5.0.0-alpha
git log -1
git submodule update --init --recursive
~~Continue on in building OpenCV with CMake, should now give no errors.~~
Actually this did not solved the issue, seems like I get the issue back once I start enabling BUILD_opencv_world feature...
If I disable BUILD_opencv_world, OpenCV CMake properly produces a proper configuration operation.
Yes,when BUILD_opencv_world is checked,the error come out,but if disable BUILD_opencv_world ,there will be lots of dlls
(I’m sorry there are no test environment on my PC. )
It looks like 'CMAKE_CURRENT_SOURCE_DIR' should be added in LINE6 .
opencv_contrib/modules/xobjdetect/tools -> ${CMAKE_CURRENT_SOURCE_DIR}/tools
opencv_contrib/modules/xobjdetect/data -> ${CMAKE_CURRENT_SOURCE_DIR}/data
set(the_description "Object detection algorithms")
ocv_define_module(xobjdetect opencv_core opencv_imgproc opencv_imgcodecs opencv_features WRAP python java objc js)
if (BUILD_opencv_apps AND NOT APPLE_FRAMEWORK)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools ${CMAKE_CURRENT_BINARY_DIR}/tools)
endif()
- add_subdirectory(data)
+ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_BINARY_DIR}/data)
I can reproduce this problem in Ubuntu 24.11.
If only set ${CMAKE_CURRENT_SOURCE_DIR} on data, following error is shown.
CMake Error at /home/kmtr/work/opencv_contrib5/modules/xobjdetect/CMakeLists.txt:6 (add_subdirectory):
add_subdirectory not given a binary directory but the given source
directory "/home/kmtr/work/opencv_contrib5/modules/xobjdetect/data" is not
a subdirectory of "/home/kmtr/work/opencv5/modules/world". When specifying
an out-of-tree source a binary directory must be explicitly specified.
Call Stack (most recent call first):
modules/world/CMakeLists.txt:13 (include)
modules/world/CMakeLists.txt:50 (include_one_module)
So ${CMAKE_CURRENT_BINARY_DIR}/data is needed.
- add_subdirectory(data)
+ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_BINARY_DIR}/data)
cannopsmay have same problem. (world->cannops->ascendc_kernel) But I have no test environment.cudevis OK, becausetestis not included whenworldis enabled.juliaandmatlabmay have same problem. (world->*->test).sfmseems be OK. (world->sfm->libmv_light)- xobjdetect-tools seems be OK. (
world->xobjdetect->tools->waldboost_detectororannotationorvisualisation) - xobjdetect-data have this problem (
world->xobjdetect->data)
kmtr@kmtr-VMware-Virtual-Platform:~/work/opencv_contrib5$ git grep add_subdirectory
modules/cannops/CMakeLists.txt:add_subdirectory(ascendc_kernels)
modules/cudev/CMakeLists.txt: add_subdirectory(test)
modules/julia/CMakeLists.txt: add_subdirectory(test)
modules/matlab/CMakeLists.txt: add_subdirectory(test)
modules/sfm/CMakeLists.txt:add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/src/libmv_light" "${CMAKE_CURRENT_BINARY_DIR}/src/libmv")
modules/sfm/src/libmv_light/CMakeLists.txt:add_subdirectory(libmv)
modules/sfm/src/libmv_light/libmv/CMakeLists.txt:add_subdirectory(correspondence)
modules/sfm/src/libmv_light/libmv/CMakeLists.txt:add_subdirectory(multiview)
modules/sfm/src/libmv_light/libmv/CMakeLists.txt:add_subdirectory(numeric)
modules/sfm/src/libmv_light/libmv/CMakeLists.txt: add_subdirectory(simple_pipeline)
modules/xobjdetect/CMakeLists.txt: add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools ${CMAKE_CURRENT_BINARY_DIR}/tools)
modules/xobjdetect/CMakeLists.txt:add_subdirectory(data)
modules/xobjdetect/tools/CMakeLists.txt:add_subdirectory(waldboost_detector)
modules/xobjdetect/tools/CMakeLists.txt:add_subdirectory(annotation)
modules/xobjdetect/tools/CMakeLists.txt:add_subdirectory(visualisation)
I was able to confirm that my patch works well. I have created a pull request. If possible, I would appreciate it if you could try it on a Windows environment.