So, I have been working on getting opencv with nvidia gpu support for a few days now and can't get python to import cv2 (importing precompiled opencv-python works as expected). Out of frustration I just deleted then unzipped the opencv_contrib_master and, to my surprise, a few new lines popped up in CMake:
Under Ungrouped Entries:
BUILD_OPENCV_CUDA
Under Python 3:
install path: C:/ProgramData/Anaconda3/Lib/site-packages/cv2/python-3.7
Under OpenCV:
OPENCV_PYTHON3_VERSION
Great. Progress. But now a new foe appears:
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:967 (include)
The above error is mentioned here and states the error is related to the python configuration. I thought the PY3 config looked ok:
PYTHON3_EXECUTABLE C:/ProgramData/Anaconda3/python.exe
PYTHON3_INCLUDE_DIR C:/ProgramData/Anaconda3/include
PYTHON3_INCLUDE_DIR2
PYTHON3_LIBRARY C:/ProgramData/Anaconda3/libs/python37.lib
PYTHON3_LIBRARY_DEBUG PYTHON_DEBUG_LIBRARY-NOTFOUND
PYTHON3_NUMPY_INCLUDE_DIRS C:/ProgramData/Anaconda3/Lib/site-packages/numpy/core/include
PYTHON3_PACKAGE_PATH C:/ProgramData/Anaconda3/Lib/site-packages
Edit 10: on a subsequent installation I saw Cmake enters numpy library from User/Roaming instead of ProgramData/Anaconda3. I do not know if the difference affects build success.
I noticed these were missing (not sure if it matters):
CUDA_nvToolsExt_LIBRARY-NOTFOUND
CUDA_nvcuvenc_LIBRARY-NOTFOUND
CUDA_nvcuvid_LIBRARY-NOTFOUND
Along with BLAS/LAPLACK/EIGEN. I still am not unclear whether these are necessary for python handle.
Using GTX 1080, so I only kept gpu arch version 6.1. Omitting other versions cut build time from 2hr15min to ~30min:
Pascal (CUDA 8 and later)
SM60 or SM_60, compute_60 – Quadro GP100, Tesla P100, DGX-1 (Generic Pascal)
SM61 or SM_61, compute_61 – GTX 1080, GTX 1070, GTX
Full Build Specs from CMake:
Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
Detected processor: AMD64
libjpeg-turbo: VERSION = 2.0.4, BUILD = opencv-4.3.0-dev-libjpeg-turbo
Found OpenJPEG: openjp2 (found version "2.3.0")
found Intel IPP (ICV version): 2020.0.0 [2020.0.0 Gold]
at: C:/Users/---/Downloads/opencv-master/build/3rdparty/ippicv/ippicv_win/icv
found Intel IPP Integration Wrappers sources: 2020.0.0
at: C:/Users/---/Downloads/opencv-master/build/3rdparty/ippicv/ippicv_win/iw
CUDA detected: 10.0
CUDA NVCC target flags: -gencode;arch=compute_61,code=sm_61;-D_FORCE_INLINES
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: C:/Users/---/Downloads/opencv-master/build/python_loader
Module opencv_alphamat disabled because the following dependencies are not found: Eigen
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
Tesseract: NO
Allocator metrics storage type: 'long long'
Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': C:/Users/---/Downloads/opencv-master/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
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:967 (include)
General configuration for OpenCV 4.3.0-dev =====================================
Version control: unknown
Extra modules:
Location (extra): C:/Users/---/Downloads/opencv_contrib-master/modules
Version control (extra): unknown
Platform:
Timestamp: 2020-04-27T18:31:30Z
Host: Windows 10.0.18363 AMD64
CMake: 3.17.1
CMake generator: Visual Studio 15 2017
CMake build tool: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/MSBuild/15.0/Bin/MSBuild.exe
MSVC: 1916
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 (16 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 (30 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
AVX512_SKX (6 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/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe (ver 19.16.27039.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/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/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: cudart_static.lib nppc.lib nppial.lib nppicc.lib nppicom.lib nppidei.lib nppif.lib nppig.lib nppim.lib nppist.lib nppisu.lib nppitc.lib npps.lib cublas.lib cudnn.lib cufft.lib -LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0/lib/x64 -LIBPATH:C:/Users/---/Downloads/cudnn-10.0-windows10-x64-v7.6.5.32/cuda/lib/x64
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 dnn_superres dpm face features2d flann fuzzy gapi hdf hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor ml objdetect optflow phase_unwrapping photo plot python3 pythoncuda quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
Disabled: world (i have this enabled in another attempt- and included it in env path)
Disabled by dependency: -
Unavailable: alphamat cnn_3dobj cvv freetype java js matlab ovis python2 sfm viz
Applications: tests perf_tests 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.4-62)
WEBP: build (ver encoder: 0x020f)
PNG: build (ver 1.6.37)
TIFF: build (ver 42 - 4.0.10)
JPEG 2000: OpenJPEG (ver 2.3.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.54.100)
avformat: YES (58.29.100)
avutil: YES (56.31.100)
swscale: YES (5.5.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/---/Downloads/opencv-master/build/3rdparty/ippicv/ippicv_win/icv
Intel IPP IW: sources (2020.0.0)
at: C:/Users/---/Downloads/opencv-master/build/3rdparty/ippicv/ippicv_win/iw
Eigen: NO
Custom HAL: NO
Protobuf: build (3.5.1)
NVIDIA CUDA: YES (ver 10.0, CUFFT CUBLAS FAST_MATH)
NVIDIA GPU arch: 61
NVIDIA PTX archs:
cuDNN: YES (ver 7.6.5)
OpenCL: YES (NVD3D11)
Include path: C:/Users/---/Downloads/opencv-master/3rdparty/include/opencl/1.2
Link libraries: Dynamic load
Python 3:
Interpreter: C:/ProgramData/Anaconda3/python.exe (ver 3.7.7)
Libraries: C:/ProgramData/Anaconda3/libs/python37.lib (ver 3.7.7)
numpy: C:/ProgramData/Anaconda3/Lib/site-packages/numpy/core/include (ver 1.15.0)
install path: C:/ProgramData/Anaconda3/Lib/site-packages/cv2/python-3.7
Python (for build): C:/ProgramData/Anaconda3/python.exe
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Install to: C:/Users/---/Downloads/opencv-master/build/install
-----------------------------------------------------------------
Configuring done
Am I missing something? Help!
edit:
These messages now pop up after Visual Studio Build
edit2: Now getting this on INSTALL build:
C:\Users---\Downloads\opencv-master\build\modules\highgui\opencv_highgui.vcxproj : error : The project file could not be loaded. Data at the root level is invalid. Line 260, position 11. C:\Users---\Downloads\opencv-master\build\modules\highgui\opencv_highgui.vcxproj
edit3:
I deleted and unzipped opencv-master to start fresh, again, and now on CMake Configure I get:
CMake Error at modules/videoio/cmake/detect_ffmpeg.cmake:16 (include):
include could not find load file:
C:/Users/---/Downloads/opencv-master/build/3rdparty/ffmpeg/ffmpeg_version.cmake
Call Stack (most recent call first):
modules/videoio/cmake/init.cmake:3 (include)
modules/videoio/cmake/init.cmake:22 (add_backend)
cmake/OpenCVModule.cmake:312 (include)
cmake/OpenCVModule.cmake:375 (_add_modules_1)
modules/CMakeLists.txt:7 (ocv_glob_modules)
CMake Warning at C:/Users/---/Downloads/opencv-master/cmake/OpenCVModule.cmake:679 (message):
Unexpected include:
C:/Users/---/Downloads/opencv-master/build/downloads/xfeatures2d
(module=opencv_xfeatures2d)
Call Stack (most recent call first):
C:/Users/---/Downloads/opencv-master/cmake/OpenCVModule.cmake:710 (ocv_target_include_modules)
C:/Users/---/Downloads/opencv_contrib-master/modules/xfeatures2d/CMakeLists.txt:17 (ocv_module_include_directories)
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:967 (include)
edit4:
Deleted opencv-master/opencv-contrib-master and reran CMake. I noticed this warning when I first configure CMake. Might be related to config error above...?
CMake Warning at cmake/OpenCVDetectPython.cmake:81 (message):
CMake's 'find_host_package(PythonInterp 2.7)' found wrong Python version:
PYTHON_EXECUTABLE=C:/ProgramData/Anaconda3/python.exe
PYTHON_VERSION_STRING=3.7.7
Consider providing the 'PYTHON2_EXECUTABLE' variable via CMake command line
or environment variables
Call Stack (most recent call first):
cmake/OpenCVDetectPython.cmake:271 (find_python)
CMakeLists.txt:598 (include)
Edit 5:
Visual Studio output:
CMake Error at modules/python3/cmake_install.cmake:93 (file):
197> file INSTALL cannot find
197> "C:/Users/---/Documents/opencv_folder/opencv-master/opencv-master/build/lib/python3/Release/cv2.cp37-win_amd64.pyd":
197> File exists.
197>Call Stack (most recent call first):
197> modules/cmake_install.cmake:192 (include)
197> cmake_install.cmake:120 (include)
From anaconda CLI:
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\ProgramData\Anaconda3\lib\cv2\__init__.py", line 96, in <module>
bootstrap()
File "C:\ProgramData\Anaconda3\lib\cv2\__init__.py", line 62, in bootstrap
], True)
File "C:\ProgramData\Anaconda3\lib\cv2\__init__.py", line 56, in load_first_config
raise ImportError('OpenCV loader: missing configuration file: {}. Check OpenCV installation.'.format(fnames))
ImportError: OpenCV loader: missing configuration file: ['config-3.7.py', 'config-3.py']. Check OpenCV installation.
Edit 6:
Visual Studio Completed a build (againx8) with no errors.
>>> import cv2
['', 'C:\\ProgramData\\Anaconda3\\python.exe', 'C:\\ProgramData\\Anaconda3\\python37.zip', 'C:\\ProgramData\\Anaconda3\\DLLs', 'C:\\ProgramData\\Anaconda3\\lib', 'C:\\ProgramData\\Anaconda3', 'C:\\Users\\---\\AppData\\Roaming\\Python\\Python37\\site-packages', 'C:\\ProgramData\\Anaconda3\\lib\\site-packages', 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\win32', 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\win32\\lib', 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\Pythonwin']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\ProgramData\Anaconda3\lib\cv2\__init__.py", line 96, in <module>
bootstrap()
File "C:\ProgramData\Anaconda3\lib\cv2\__init__.py", line 23, in bootstrap
raise ImportError('ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.')
ImportError: ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.
Deleting cv2 from "C:\ProgramData\Anaconda3\Lib" creates module not found error.
Deleting cv2 from "C:\ProgramData\Anaconda3\Lib\Site-Packages" creates dll error.
Deleting both slightly increases the number of hours I've spent on this setup.
I compiled with cv2world enabled and disabled and set cv2world.dll in env path and copied to ProgramData\Anaconda\Lib.
Edit 7:
All of my once partitioned R environments are broken and my computer now runs quite poorly (explorer gets stuck on 99% when transferring files regardless of size; significantly increased boot times). There is now an errant Python3.6 installation. It might be time to reinstall windows.
Edit 8:
import cv2
Traceback (most recent call last):
File "<ipython-input-1-c8ec22b3e787>", line 1, in <module>
import cv2
File "C:\Users\Arman\AppData\Roaming\Python\Python37\site-packages\cv2\__init__.py", line 89, in <module>
bootstrap()
File "C:\Users\Arman\AppData\Roaming\Python\Python37\site-packages\cv2\__init__.py", line 62, in bootstrap
], True)
File "C:\Users\Arman\AppData\Roaming\Python\Python37\site-packages\cv2\__init__.py", line 56, in load_first_config
raise ImportError('OpenCV loader: missing configuration file: {}. Check OpenCV installation.'.format(fnames))
ImportError: OpenCV loader: missing configuration file: ['config-3.7.py', 'config-3.py']. Check OpenCV installation.
I tried ctrl+cv the config files but that changed error to one of recursion . No working opencv with cuda as of yet.
Edit 9:
Still no module being exported to Anaconda library.
Maybe it is related to this: Opencv fatal error LNK1120: 143 unresolved externals
opencv-folder\opencv-master\build\bin\Release\opencv_world430.dll : fatal error LNK1120: 143 unresolved externals
25>Done building project "opencv_world.vcxproj" -- FAILED.
26>------ Build started: Project: opencv_ts, Configuration: Release x64 ------
27>------ Build started: Project: opencv_img_hash, Configuration: Release x64 ------
28>------ Build started: Project: opencv_waldboost_detector, Configuration: Release x64 ------
29>------ Build started: Project: opencv_annotation, Configuration: Release x64 ------
30>------ Build started: Project: opencv_interactive-calibration, Configuration: Release x64 ------
31>------ Build started: Project: opencv_version, Configuration: Release x64 ------
32>------ Build started: Project: opencv_version_win32, Configuration: Release x64 ------
33>------ Build started: Project: opencv_visualisation, Configuration: Release x64 ------
Edit nsomething:
From module not found to recursion detected:
(base) C:\Users\---\Documents\SystemConfig\opencv-folder\opencv-master\build\python_loader>python setup.py build
running build
running build_py
(base) C:\Users\---\Documents\SystemConfig\opencv-folder\opencv-master\build\python_loader>python setup.py install
running install
running bdist_egg
running egg_info
writing opencv.egg-info\PKG-INFO
writing dependency_links to opencv.egg-info\dependency_links.txt
writing requirements to opencv.egg-info\requires.txt
writing top-level names to opencv.egg-info\top_level.txt
reading manifest file 'opencv.egg-info\SOURCES.txt'
writing manifest file 'opencv.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
creating build\bdist.win-amd64\egg
creating build\bdist.win-amd64\egg\cv2
copying build\lib\cv2\config-2.7.py -> build\bdist.win-amd64\egg\cv2
copying build\lib\cv2\config-3.7.py -> build\bdist.win-amd64\egg\cv2
copying build\lib\cv2\config.py -> build\bdist.win-amd64\egg\cv2
copying build\lib\cv2\load_config_py2.py -> build\bdist.win-amd64\egg\cv2
copying build\lib\cv2\load_config_py3.py -> build\bdist.win-amd64\egg\cv2
copying build\lib\cv2\__init__.py -> build\bdist.win-amd64\egg\cv2
byte-compiling build\bdist.win-amd64\egg\cv2\config-2.7.py to config-2.7.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\cv2\config-3.7.py to config-3.7.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\cv2\config.py to config.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\cv2\load_config_py2.py to load_config_py2.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\cv2\load_config_py3.py to load_config_py3.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\cv2\__init__.py to __init__.cpython-37.pyc
creating build\bdist.win-amd64\egg\EGG-INFO
copying opencv.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO
copying opencv.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying opencv.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying opencv.egg-info\requires.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying opencv.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO
zip_safe flag not set; analyzing archive contents...
cv2.__pycache__.__init__.cpython-37: module references __file__
creating 'dist\opencv-4.3.0-py3.7.egg' and adding 'build\bdist.win-amd64\egg' to it
removing 'build\bdist.win-amd64\egg' (and everything under it)
Processing opencv-4.3.0-py3.7.egg
removing 'a:\programdata\anaconda3\lib\site-packages\opencv-4.3.0-py3.7.egg' (and everything under it)
creating a:\programdata\anaconda3\lib\site-packages\opencv-4.3.0-py3.7.egg
Extracting opencv-4.3.0-py3.7.egg to a:\programdata\anaconda3\lib\site-packages
opencv 4.3.0 is already the active version in easy-install.pth
Installed a:\programdata\anaconda3\lib\site-packages\opencv-4.3.0-py3.7.egg
Processing dependencies for opencv==4.3.0
Searching for numpy==1.18.1
Best match: numpy 1.18.1
Adding numpy 1.18.1 to easy-install.pth file
Installing f2py-script.py script to A:\ProgramData\Anaconda3\Scripts
Installing f2py.exe script to A:\ProgramData\Anaconda3\Scripts
Using a:\programdata\anaconda3\lib\site-packages
Finished processing dependencies for opencv==4.3.0
(base) C:\Users\---\Documents\SystemConfig\opencv-folder\opencv-master\build\python_loader>
In the OpenCV forum thread OpenCV build for Windows x64/Python3.7 from source. Where is the .pyd file?, there is a comment (by KTeddy, I believe) that solved it for me:
If your python interpreter is not official, you can try the official version.
Details: I have used anaconda python to build opencv, but the same as your question, there isn't BUILD_opencv_python3 in cmake gui, as a result I can't get a .pyd file. I come across a comment that anaconda and cmake have compatibility problems. Finally I solved it by installing official python version.
Related
recently I wanted to build OpenCV to run with CUDA support, but every time when I try to build it it gives me this error:
F:\OpenCV\openCVGPU\opencv-4.7.0\modules\python\src2\cv2.hpp(20,10): fatal error C1083: Cannot open include file: 'Pyt
hon.h': No such file or directory (compiling source file F:\OpenCV\openCVGPU\opencv-4.7.0\modules\python\src2\cv2_highg
ui.cpp) [F:\Build\modules\python3\opencv_python3.vcxproj]
F:\OpenCV\openCVGPU\opencv-4.7.0\modules\python\src2\cv2.hpp(20,10): fatal error C1083: Cannot open include file: 'Pyt
hon.h': No such file or directory (compiling source file F:\OpenCV\openCVGPU\opencv-4.7.0\modules\python\src2\cv2.cpp)
[F:\Build\modules\python3\opencv_python3.vcxproj]
F:\OpenCV\openCVGPU\opencv-4.7.0\modules\python\src2\cv2.hpp(20,10): fatal error C1083: Cannot open include file: 'Pyt
hon.h': No such file or directory (compiling source file F:\OpenCV\openCVGPU\opencv-4.7.0\modules\python\src2\cv2_numpy
.cpp) [F:\Build\modules\python3\opencv_python3.vcxproj]
F:\OpenCV\openCVGPU\opencv-4.7.0\modules\python\src2\cv2.hpp(20,10): fatal error C1083: Cannot open include file: 'Pyt
hon.h': No such file or directory (compiling source file F:\OpenCV\openCVGPU\opencv-4.7.0\modules\python\src2\cv2_util.
cpp) [F:\Build\modules\python3\opencv_python3.vcxproj]
F:\OpenCV\openCVGPU\opencv-4.7.0\modules\python\src2\cv2.hpp(20,10): fatal error C1083: Cannot open include file: 'Pyt
hon.h': No such file or directory (compiling source file F:\OpenCV\openCVGPU\opencv-4.7.0\modules\python\src2\cv2_conve
Python Version is 3.9
OpenCV is pulled from GitHub at 17/02/2023 - Version 4.7.0
OpenCV Contrib is also pulled from Github - Version 4.x
I also tried to install Build Tools for Visual Studio 2022
Am using Visual Studio 2022 with Cmake, the Cmake configuration is:
General configuration for OpenCV 4.7.0 =====================================
Version control: unknown
Extra modules:
Location (extra): F:/OpenCV/openCVGPU/opencv_contrib-4.x/modules
Version control (extra): unknown
Platform:
Timestamp: 2023-02-17T14:01:27Z
Host: Windows 10.0.19044 AMD64
CMake: 3.24.2
CMake generator: Visual Studio 17 2022
CMake build tool: C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe
MSVC: 1933
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 (18 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 (34 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/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe (ver 19.33.31630.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 /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:fast /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /wd4819 /MP /MDd /Zi /Ob0 /Od /RTC1
C Compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/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 /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:fast /MP /MDd /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:/CUDA/lib/x64 -LIBPATH:F:/CUDA/lib
3rdparty dependencies:
OpenCV modules:
To be built: aruco barcode bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev 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 python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode world xfeatures2d ximgproc xobjdetect xphoto
Disabled: -
Disabled by dependency: -
Unavailable: alphamat cvv freetype hdf java julia matlab ovis python2 python2 sfm viz
Applications: tests perf_tests 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.13)
JPEG: build-libjpeg-turbo (ver 2.1.3-62)
SIMD Support Request: YES
SIMD Support: NO
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: F:/Build/3rdparty/ippicv/ippicv_win/icv
Intel IPP IW: sources (2020.0.0)
at: F:/Build/3rdparty/ippicv/ippicv_win/iw
Lapack: NO
Eigen: NO
Custom HAL: NO
Protobuf: build (3.19.1)
NVIDIA CUDA: YES (ver 11.8, CUFFT CUBLAS FAST_MATH)
NVIDIA GPU arch: 75
NVIDIA PTX archs: 75
cuDNN: YES (ver 8.5.0)
OpenCL: YES (NVD3D11)
Include path: F:/OpenCV/openCVGPU/opencv-4.7.0/3rdparty/include/opencl/1.2
Link libraries: Dynamic load
Python 3:
Interpreter: C:/Users/Rufo123/AppData/Local/Programs/Python/Python39/python.exe (ver 3.10.9)
Libraries: C:/Users/Rufo123/AppData/Local/Programs/Python/Python310/libs/python310.lib (ver 3.10.9)
numpy: C:/Users/Rufo123/AppData/Local/Programs/Python/Python39/Lib/site-packages/numpy/core/include (ver )
install path: C:/Users/Rufo123/AppData/Local/Programs/Python/Python39/Lib/site-packages/cv2/python-3.10
Python (for build): C:/Users/Rufo123/AppData/Local/Programs/Python/Python39/python.exe
Java:
ant: NO
JNI: C:/Program Files/Eclipse Adoptium/jdk-17.0.3.7-hotspot/include C:/Program Files/Eclipse Adoptium/jdk-17.0.3.7-hotspot/include/win32 C:/Program Files/Eclipse Adoptium/jdk-17.0.3.7-hotspot/include
Java wrappers: NO
Java tests: NO
Install to: F:/Build/install
I also made sure that all Environment Variables in Path are set.
Could you please help me with the build error?
(Also note, that I am using Windows 10)
Hi so after a lot of trial and error, I finally built it successfully and also resolved import cv2 not working.
So First of all I noticed that Cmake somehow assigned wrong version of python
I am using 3.9.11. Here:
Python 3:
Interpreter: C:/Users/Rufo123/AppData/Local/Programs/Python/Python39/python.exe (ver 3.10.9)
Libraries: C:/Users/Rufo123/AppData/Local/Programs/Python/Python310/libs/python310.lib (ver 3.10.9)
numpy: C:/Users/Rufo123/AppData/Local/Programs/Python/Python39/Lib/site-packages/numpy/core/include (ver )
install path: C:/Users/Rufo123/AppData/Local/Programs/Python/Python39/Lib/site-packages/cv2/python-3.10
After reseting cache now it looks like this:
Python 3:
Interpreter: C:/Users/Rufo123/AppData/Local/Programs/Python/Python39/python.exe (ver 3.9.11)
Libraries: C:/Users/Rufo123/AppData/Local/Programs/Python/Python39/libs/python39.lib (ver 3.9.11)
numpy: C:/Users/Rufo123/AppData/Local/Programs/Python/Python39/lib/site-packages/numpy/core/include (ver 1.24.2)
install path: C:/Users/Rufo123/AppData/Local/Programs/Python/Python39/Lib/site-packages/cv2/python-3.9
After this, the build succeded without errors. But there was another catch, after trying to import cv2. This error occured:
ImportError: DLL load failed while importing cv2: The specified module could not be found
So I Updated System Environment Variables (PATH and PYTHONPATH) and included everything that came to my mind:
PATH:
f:\Build\lib\python3\Release\
f:\Build\
f:\Build\install\x64\vc17\bin\
F:\CUDA\bin
F:\CUDA\libnvvp
PYTHONPATH:
f:\Build\python_loader\
f:\Build\bin\Release\
After this the error slightly changed and I noticed that now, the python can actually see the built OpenCV Library.
So I googled a lot and this post helped me: importerror-dll-load-failed-while-importing-cv2-the-specified-module-could-not-be-found
And I edited the config.py in python_loader/cv2
import os
BINARIES_PATHS = [
'F:/Build/bin/Release',
os.path.join('f:\Build\install', 'x64\vc17\bin'),
os.path.join(os.getenv('CUDA_PATH', 'c:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8'), 'bin')
] + BINARIES_PATHS
So after all I think that 'CUDA_PATH' variable vas missing from System Environment Variables.
Also thanks to #Brian for pointing me in the right direction.
I was trying to install OpenCV-4.5.5 from source on my windows machine. This machine has the latest Nvidia drivers as well as CUDA 11.6, I did not run into any issue with those. On the other hand I wanted to install OpenCV with the GStreamer dependencies, I previously installed the library and had no issues as well.
My main problem is that I wanted to generate the python3 bindings but when I reach the installation part, build already completed without issues, I run into the following error:
CMake Error at C:/OpenCV-4.5.5/build/modules/python3/cmake_install.cmake:153 (file):
file INSTALL cannot find
"C:/OpenCV-4.5.5/build/lib/python3/Release/cv2.cp39-win_amd64.pyd": File
exists.
Call Stack (most recent call first):
C:/OpenCV-4.5.5/build/cmake_install.cmake:291 (include)
I used a .bat script to configure the CMake build:
-D CMAKE_INSTALL_PREFIX=C:/OpenCV-4.5.5/install ^
-D OPENCV_EXTRA_MODULES_PATH=C:/Users/%USERNAME%/Downloads/opencv_contrib-4.5.5/opencv_contrib-4.5.5/modules ^
-D ENABLE_FAST_MATH=ON ^
-D CUDA_FAST_MATH=ON ^
-D WITH_CUDA=ON ^
-D WITH_CUDNN=ON ^
-D OPENCV_DNN_CUDA=ON ^
-D CUDA_ARCH_BIN=8.6 ^
-D WITH_OPENGL=ON ^
-D WITH_GSTREAMER=ON ^
-D BUILD_opencv_python3=ON ^
-D PYTHON3_EXECUTABLE=C:/Users/%USERNAME%/AppData/Local/Programs/Python/Python39/python.exe ^
-D PYTHON3_INCLUDE_DIR=C:/Users/%USERNAME%/AppData/Local/Programs/Python/Python39/include ^
-D PYTHON3_LIBRARY=C:/Users/%USERNAME%/AppData/Local/Programs/Python/Python39/libs/python39.lib ^
-D PYTHON3_NUMPY_INCLUDE_DIRS=C:/Users/%USERNAME%/AppData/Local/Programs/Python/Python39/Lib/site-packages/numpy/core/include ^
-D PYTHON3_PACKAGES_PATH=C:/Users/%USERNAME%/AppData/Local/Programs/Python/Python39/Lib/site-packages ^
-D CMAKE_CONFIGURATIONS_TYPES=Release ^
-G "Visual Studio 17 2022" ^
-S C:/Users/%USERNAME%/Downloads/opencv-4.5.5/opencv-4.5.5 -B C:/OpenCV-4.5.5/build
The output of the script is this:
-- Version control: unknown
--
-- Extra modules:
-- Location (extra): C:/Users/10655707/Downloads/opencv_contrib-4.5.5/opencv_contrib-4.5.5/modules
-- Version control (extra): unknown
--
-- Platform:
-- Timestamp: 2022-01-28T07:26:17Z
-- Host: Windows 10.0.19044 AMD64
-- CMake: 3.22.1
-- CMake generator: Visual Studio 17 2022
-- CMake build tool: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/MSBuild/Current/Bin/amd64/MSBuild.exe
-- MSVC: 1930
-- 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 (18 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 (33 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/2022/BuildTools/VC/Tools/MSVC/14.30.30705/bin/Hostx64/x64/cl.exe (ver 19.30.30709.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 /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:fast /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP /MDd /Zi /Ob0 /Od /RTC1
-- C Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.30.30705/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 /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:fast /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: 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:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6/lib/x64 -LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.6/lib
-- 3rdparty dependencies:
--
-- OpenCV modules:
-- To be built: aruco barcode bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev 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 python3 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: alphamat cvv freetype hdf java julia matlab ovis python2 sfm viz
-- Applications: tests perf_tests apps
-- Documentation: NO
-- Non-free algorithms: NO
--
-- Windows RT support: NO
--
-- GUI: WIN32UI
-- Win32 UI: YES
-- OpenGL support: YES (opengl32 glu32)
-- VTK support: NO
--
-- Media I/O:
-- ZLib: build (ver 1.2.11)
-- JPEG: build-libjpeg-turbo (ver 2.1.2-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: YES (1.18.5)
-- 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:/OpenCV-4.5.5/build/3rdparty/ippicv/ippicv_win/icv
-- Intel IPP IW: sources (2020.0.0)
-- at: C:/OpenCV-4.5.5/build/3rdparty/ippicv/ippicv_win/iw
-- Lapack: NO
-- Eigen: NO
-- Custom HAL: NO
-- Protobuf: build (3.19.1)
--
-- NVIDIA CUDA: YES (ver 11.6, CUFFT CUBLAS FAST_MATH)
-- NVIDIA GPU arch: 86
-- NVIDIA PTX archs:
--
-- cuDNN: YES (ver 8.3.2)
--
-- OpenCL: YES (NVD3D11)
-- Include path: C:/Users/10655707/Downloads/opencv-4.5.5/opencv-4.5.5/3rdparty/include/opencl/1.2
-- Link libraries: Dynamic load
--
-- Python 3:
-- Interpreter: C:/Users/10655707/AppData/Local/Programs/Python/Python39/python.exe (ver 3.9.10)
-- Libraries: C:/Users/10655707/AppData/Local/Programs/Python/Python39/libs/python39.lib (ver 3.9.10)
-- numpy: C:/Users/10655707/AppData/Local/Programs/Python/Python39/Lib/site-packages/numpy/core/include (ver 1.22.1)
-- install path: C:/Users/10655707/AppData/Local/Programs/Python/Python39/Lib/site-packages/cv2/python-3.9
--
-- Python (for build): C:/Users/10655707/AppData/Local/Programs/Python/Python39/python.exe
--
-- Java:
-- ant: NO
-- JNI: NO
-- Java wrappers: NO
-- Java tests: NO
--
-- Install to: C:/OpenCV-4.5.5/install
-- -----------------------------------------------------------------
--
-- Configuring done
-- Generating done
-- Build files have been written to: C:/OpenCV-4.5.5/build
Then, in the build folder, I just did a
cmake --build . --target INSTALL --config Release -j10
cmake --install .
Any idea why I may be running into this issue?
I haven't been able to figure out why does this happen only with this binding.
I have built OpenCV with Cuda for Python and am using the following lines to use GPU.
net = cv2.dnn.readNetFromCaffe(proto_file, weights_file)
net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)
However, my FPS with GPU is about 1.8 while it is about 0.8 with CPU. In the task manager, my GPU utilization is displayed as about 5%.
My GPU is Nvidia GeForce MX130. How can I increase my GPU utilization and hence, my FPS?
To verify that my OpenCV installation allows GPU processing, I have used the following statements with the respective outputs.
cv2.cuda.getCudaEnabledDeviceCount()
Output 1.
cv2.getBuildInformation()
Output:
'\nGeneral configuration for OpenCV 4.4.0 =====================================\n Version control: unknown\n\n Extra modules:\n Location (extra): G:/opencv_contrib-4.4.0/opencv_contrib-4.4.0/modules\n Version control (extra): unknown\n\n Platform:\n Timestamp: 2021-09-24T15:28:43Z\n Host: Windows 10.0.19043 AMD64\n CMake: 3.21.1\n CMake generator: Visual Studio 16 2019\n CMake build tool: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe\n MSVC: 1929\n\n CPU/HW features:\n Baseline: SSE SSE2 SSE3\n requested: SSE3\n Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX\n requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX\n SSE4_1 (17 files): + SSSE3 SSE4_1\n SSE4_2 (2 files): + SSSE3 SSE4_1 POPCNT SSE4_2\n FP16 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX\n AVX (5 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX\n AVX2 (31 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2\n AVX512_SKX (7 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX\n\n C/C++:\n Built as dynamic libs?: YES\n C++ standard: 11\n C++ Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe (ver 19.29.30133.0)\n 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 /MP /MD /O2 /Ob2 /DNDEBUG \n 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 /MP /MDd /Zi /Ob0 /Od /RTC1 \n C Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe\n 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 /MD /O2 /Ob2 /DNDEBUG \n 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 /MDd /Zi /Ob0 /Od /RTC1 \n Linker flags (Release): /machine:x64 /INCREMENTAL:NO \n Linker flags (Debug): /machine:x64 /debug /INCREMENTAL \n ccache: NO\n Precompiled headers: NO\n Extra dependencies: cudart_static.lib nppc.lib nppial.lib nppicc.lib nppicom.lib nppidei.lib nppif.lib nppig.lib nppim.lib nppist.lib nppisu.lib nppitc.lib npps.lib cublas.lib cudnn.lib cufft.lib -LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1/lib/x64\n 3rdparty dependencies:\n\n OpenCV modules:\n 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 dnn_superres dpm face features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab world xfeatures2d ximgproc xobjdetect xphoto\n Disabled: -\n Disabled by dependency: -\n Unavailable: alphamat cnn_3dobj cvv freetype hdf java js julia matlab ovis python2 python2 sfm viz\n Applications: tests perf_tests apps\n Documentation: NO\n Non-free algorithms: NO\n\n Windows RT support: NO\n\n GUI: \n Win32 UI: YES\n VTK support: NO\n\n Media I/O: \n ZLib: build (ver 1.2.11)\n JPEG: build-libjpeg-turbo (ver 2.0.5-62)\n WEBP: build (ver encoder: 0x020f)\n PNG: build (ver 1.6.37)\n TIFF: build (ver 42 - 4.0.10)\n JPEG 2000: build Jasper (ver 1.900.1)\n OpenEXR: build (ver 2.3.0)\n HDR: YES\n SUNRASTER: YES\n PXM: YES\n PFM: YES\n\n Video I/O:\n DC1394: NO\n FFMPEG: YES (prebuilt binaries)\n avcodec: YES (58.54.100)\n avformat: YES (58.29.100)\n avutil: YES (56.31.100)\n swscale: YES (5.5.100)\n avresample: YES (4.0.0)\n GStreamer: NO\n DirectShow: YES\n Media Foundation: YES\n DXVA: YES\n\n Parallel framework: Concurrency\n\n Trace: YES (with Intel ITT)\n\n Other third-party libraries:\n Intel IPP: 2020.0.0 Gold [2020.0.0]\n at: G:/opencv-gpu-build/3rdparty/ippicv/ippicv_win/icv\n Intel IPP IW: sources (2020.0.0)\n at: G:/opencv-gpu-build/3rdparty/ippicv/ippicv_win/iw\n Lapack: NO\n Eigen: NO\n Custom HAL: NO\n Protobuf: build (3.5.1)\n\n NVIDIA CUDA: YES (ver 10.1, CUFFT CUBLAS FAST_MATH)\n NVIDIA GPU arch: 50\n NVIDIA PTX archs:\n\n cuDNN: YES (ver 7.6.5)\n\n OpenCL: YES (NVD3D11)\n Include path: G:/opencv-4.4.0/opencv-4.4.0/3rdparty/include/opencl/1.2\n Link libraries: Dynamic load\n\n Python 3:\n Interpreter: G:/python-projects/human-pose-estimation/venv/Scripts/python.exe (ver 3.9.6)\n Libraries: C:/Users/tmakp/AppData/Local/Programs/Python/Python39/libs/python39.lib (ver 3.9.6)\n numpy: G:/python-projects/human-pose-estimation/venv/Lib/site-packages/numpy/core/include (ver 1.21.2)\n install path: G:/python-projects/human-pose-estimation/venv/Lib/site-packages/cv2/python-3.9\n\n Python (for build): G:/python-projects/human-pose-estimation/venv/Scripts/python.exe\n\n Java: \n ant: NO\n JNI: NO\n Java wrappers: NO\n Java tests: NO\n\n Install to: G:/opencv-gpu-build/install\n-----------------------------------------------------------------\n\n'
I had to reinstall anaconda and its relatives. After I done this, opencv imshow buttons(such as zoom, save, etc.) didn't show. I tried to reinstall pyqt5, opencv-python(via conda and pip) but not worked.
before;
after;
the code i tried to:
import cv2
cv2.namedWindow("output")
img = cv2.imread("C:/Users/haydarc/Desktop/yuzdeleme/IMG_2324.JPG")
cv2.imshow("Mountains", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Also i tried cv2.namedWindow("output", cv2.WINDOW_AUTOSIZE) , cv2.namedWindow("output", cv2.WINDOW_GUI_EXPANDED) , etc.
Versions
Python 3.7.7
OpenCV 4.2.0
Spyder 4.0.1
Edit
General configuration for OpenCV 4.2.0 =====================================
Version control: 4.2.0
Platform:
Timestamp: 2020-04-04T22:29:14Z
Host: Windows 6.3.9600 AMD64
CMake: 3.16.2
CMake generator: Visual Studio 14 2015 Win64
CMake build tool: C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe
MSVC: 1900
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 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
C/C++:
Built as dynamic libs?: NO
C++ Compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe (ver 19.0.24241.7)
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 /MP2 /MT /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 /MP2 /MTd /Zi /Ob0 /Od /RTC1
C Compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/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 /MP2 /MT /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 /MP2 /MTd /Zi /Ob0 /Od /RTC1
Linker flags (Release): /machine:x64 /NODEFAULTLIB:atlthunk.lib /INCREMENTAL:NO /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:libcpmtd.lib /NODEFAULTLIB:msvcrtd.lib
Linker flags (Debug): /machine:x64 /NODEFAULTLIB:atlthunk.lib /debug /INCREMENTAL /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcpmt.lib /NODEFAULTLIB:msvcrt.lib
ccache: NO
Precompiled headers: YES
Extra dependencies: ade comctl32 gdi32 ole32 setupapi ws2_32
3rdparty dependencies: ittnotify libprotobuf zlib libjpeg-turbo libwebp libpng libtiff libjasper IlmImf quirc ippiw ippicv
OpenCV modules:
To be built: calib3d core dnn features2d flann gapi highgui imgcodecs imgproc ml objdetect photo python3 stitching video videoio
Disabled: world
Disabled by dependency: -
Unavailable: java js python2 ts
Applications: -
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.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: NO
FFMPEG: YES (prebuilt binaries)
avcodec: YES (58.54.100)
avformat: YES (58.29.100)
avutil: YES (56.31.100)
swscale: YES (5.5.100)
avresample: YES (4.0.0)
GStreamer: NO
DirectShow: YES
Media Foundation: YES
DXVA: NO
Parallel framework: Concurrency
Trace: YES (with Intel ITT)
Other third-party libraries:
Intel IPP: 2019.0.0 Gold [2019.0.0]
at: C:/projects/opencv-python/_skbuild/win-amd64-3.7/cmake-build/3rdparty/ippicv/ippicv_win/icv
Intel IPP IW: sources (2019.0.0)
at: C:/projects/opencv-python/_skbuild/win-amd64-3.7/cmake-build/3rdparty/ippicv/ippicv_win/iw
Lapack: NO
Eigen: NO
Custom HAL: NO
Protobuf: build (3.5.1)
OpenCL: YES (NVD3D11)
Include path: C:/projects/opencv-python/opencv/3rdparty/include/opencl/1.2
Link libraries: Dynamic load
Python 3:
Interpreter: C:/Python37-x64/python.exe (ver 3.7.5)
Libraries: C:/Python37-x64/libs/python37.lib (ver 3.7.5)
numpy: C:/Python37-x64/lib/site-packages/numpy/core/include (ver 1.14.5)
install path: python
Python (for build): C:\Python37-x64\python.exe
Java:
ant: NO
JNI: C:/Program Files/Java/jdk1.8.0/include C:/Program Files/Java/jdk1.8.0/include/win32 C:/Program Files/Java/jdk1.8.0/include
Java wrappers: NO
Java tests: NO
Install to: C:/projects/opencv-python/_skbuild/win-amd64-3.7/cmake-install
-----------------------------------------------------------------
I am hoping to use additonal algorithms in opencv-contrib in opencv. I am trying to build opencv with the Non Free Algorithms in contrib.
I am new to using cmake.
I was able to complete the configure/generate phases in cmake build, to build opencv (Attaching the configuration). When I build using Visual Studio, there is no cv2.pyd generated.
I do see a cv2.cp37-win_amd64.pyd file though. It is already available in the site-packages folder, when I pip install the .ee file generated from the camke build.
Following was the output of the Generate Step:
Selecting Windows SDK version to target Windows 10.0.16299.
libjpeg-turbo: VERSION = 2.0.2, BUILD = opencv-4.1.0-dev-libjpeg-turbo
found Intel IPP (ICV version): 2019.0.0 [2019.0.0 Gold]
at: /openCV/opencv-master/build/3rdparty/ippicv/ippicv_win/icv
found Intel IPP Integration Wrappers sources: 2019.0.0
at: /openCV/opencv-master/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)
LAPACK requires BLAS
A library with LAPACK API not found. Please specify library location.
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: /openCV/opencv-master/build/python_loader
Excluding from source files list: modules/imgproc/src/corner.avx.cpp
Excluding from source files list: modules/imgproc/src/imgwarp.avx2.cpp
Excluding from source files list: modules/imgproc/src/imgwarp.sse4_1.cpp
Excluding from source files list: modules/imgproc/src/resize.avx2.cpp
Excluding from source files list: modules/imgproc/src/resize.sse4_1.cpp
Excluding from source files list: modules/imgproc/src/sumpixels.avx512_skx.cpp
Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': /openCV/opencv-master/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.avx.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
Excluding from source files list: modules/calib3d/src/undistort.avx2.cpp
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
OpenCL samples are skipped: OpenCL SDK is required
General configuration for OpenCV 4.1.0-dev =====================================
Version control: unknown
Platform:
Timestamp: 2019-06-17T02:43:38Z
Host: Windows 10.0.16299 AMD64
CMake: 3.15.0-rc1
CMake generator: Visual Studio 14 2015
CMake build tool: C:/Program Files (x86)/MSBuild/14.0/bin/MSBuild.exe
MSVC: 1900
CPU/HW features:
Baseline: SSE SSE2
requested: SSE2
C/C++:
Built as dynamic libs?: YES
C++ Compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe (ver 19.0.24215.1)
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 /arch:SSE /arch:SSE2 /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP8 /MD /O2 /Ob2 /DNDEBUG /Zi
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 /arch:SSE /arch:SSE2 /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP8 /MDd /Zi /Ob0 /Od /RTC1
C Compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/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 /arch:SSE /arch:SSE2 /MP8 /MD /O2 /Ob2 /DNDEBUG /Zi
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 /arch:SSE /arch:SSE2 /MP8 /MDd /Zi /Ob0 /Od /RTC1
Linker flags (Release): /machine:X86 /INCREMENTAL:NO /debug
Linker flags (Debug): /machine:X86 /debug /INCREMENTAL
ccache: NO
Precompiled headers: YES
Extra dependencies:
3rdparty dependencies:
OpenCV modules:
To be built: calib3d core dnn features2d flann gapi highgui imgcodecs imgproc ml objdetect photo stitching ts video videoio
Disabled: world
Disabled by dependency: -
Unavailable: java js python2 python3
Applications: examples apps
Documentation: NO
Non-free algorithms: YES
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.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: NO
FFMPEG: YES (prebuilt binaries)
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)
GStreamer: NO
DirectShow: YES
Media Foundation: YES
DXVA: NO
Parallel framework: Concurrency
Trace: YES (with Intel ITT)
Other third-party libraries:
Intel IPP: 2019.0.0 Gold [2019.0.0]
at: /openCV/opencv-master/build/3rdparty/ippicv/ippicv_win/icv
Intel IPP IW: sources (2019.0.0)
at: /openCV/opencv-master/build/3rdparty/ippicv/ippicv_win/iw
Lapack: NO
Eigen: NO
Custom HAL: NO
Protobuf: build (3.5.1)
OpenCL: YES (NVD3D11)
Include path: /openCV/opencv-master/3rdparty/include/opencl/1.2
Link libraries: Dynamic load
Python (for build): C:/Anaconda/python.exe
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Install to: /openCV/opencv-master/build/install
Configuring done
Generating done
I do see a .egg file created. However when i install using the .egg file, the additional algorithms SIFT/SURF are not available.
I also do see python samples in the samples folder,but no cv2.pyd file.
I was wondering if someone could guide me, in terms of getting opencv to work with the additional algorithms.