当我尝试在启用推理引擎的情况下编译 OpenCv 时,出现错误
When I try to compile OpenCv with inference engine enabled, I am getting an error
如果我尝试在启用 inferenca Engineen 的情况下构建 OpenCV 4.0.0,我会收到此错误:
1>------ Build started: Project: opencv_dnn, Configuration: Release x64 ------
1>dnn.cpp
1>C:\local\opencv-4.0.0\modules\dnn\src\dnn.cpp(1595): error C2259: 'cv::dnn::InfEngineBackendNet': cannot instantiate abstract class
1>C:\local\opencv-4.0.0\modules\dnn\src\dnn.cpp(1595): note: due to following members:
1>C:\local\opencv-4.0.0\modules\dnn\src\dnn.cpp(1595): note: 'InferenceEngine::StatusCode InferenceEngine::ICNNNetwork::serialize(const std::string &,const std::string &,InferenceEngine::ResponseDesc *) noexcept const': is abstract
1>C:\local\Intel\computer_vision_sdk_2018.5.445\deployment_tools\inference_engine\include\ie_icnn_network.hpp(190): note: see declaration of 'InferenceEngine::ICNNNetwork::serialize'
1>C:\local\opencv-4.0.0\modules\dnn\src\dnn.cpp(2556): error C2259: 'cv::dnn::InfEngineBackendNet': cannot instantiate abstract class
1>C:\local\opencv-4.0.0\modules\dnn\src\dnn.cpp(2556): note: due to following members:
1>C:\local\opencv-4.0.0\modules\dnn\src\dnn.cpp(2556): note: 'InferenceEngine::StatusCode InferenceEngine::ICNNNetwork::serialize(const std::string &,const std::string &,InferenceEngine::ResponseDesc *) noexcept const': is abstract
1>C:\local\Intel\computer_vision_sdk_2018.5.445\deployment_tools\inference_engine\include\ie_icnn_network.hpp(190): note: see declaration of 'InferenceEngine::ICNNNetwork::serialize'
1>Done building project "opencv_dnn.vcxproj" -- FAILED.
为什么我会收到这个错误?
编辑
Cmake 输出为:
Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.17134.
AVX_512F is not supported by C++ compiler
AVX512_SKX is not supported by C++ compiler
Dispatch optimization AVX512_SKX is not available, skipped
libjpeg-turbo: VERSION = 1.5.3, BUILD = opencv-4.0.0-libjpeg-turbo
Looking for Mfapi.h
Looking for Mfapi.h - found
found Intel IPP (ICV version): 2019.0.0 [2019.0.0 Gold]
at: C:/local/opencv-build/3rdparty/ippicv/ippicv_win/icv
found Intel IPP Integration Wrappers sources: 2019.0.0
at: C:/local/opencv-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)
Detected InferenceEngine: cmake package
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:/local/opencv-build/python_loader
Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx512_skx.cpp
General configuration for OpenCV 4.0.0 =====================================
Version control: unknown
Platform:
Timestamp: 2019-02-09T13:06:47Z
Host: Windows 10.0.17134 AMD64
CMake: 3.13.0-rc3
CMake generator: Visual Studio 15 2017 Win64
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
requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
SSE4_1 (7 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 (13 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/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe (ver 19.16.27026.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 /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP4 /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 /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP4 /MTd /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 /MP4 /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 /MP4 /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: IE::inference_engine 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 java_bindings_generator ml objdetect photo python3 python_bindings_generator stitching ts video videoio
Disabled: world
Disabled by dependency: -
Unavailable: java js python2
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 1.5.3-62)
WEBP: build (ver encoder: 0x020e)
PNG: build (ver 1.6.35)
TIFF: build (ver 42 - 4.0.9)
JPEG 2000: build (ver 1.900.1)
OpenEXR: build (ver 1.7.1)
HDR: YES
SUNRASTER: YES
PXM: YES
PFM: YES
Video I/O:
DC1394: NO
FFMPEG: YES (prebuilt binaries)
avcodec: YES (ver 58.35.100)
avformat: YES (ver 58.20.100)
avutil: YES (ver 56.22.100)
swscale: YES (ver 5.3.100)
avresample: YES (ver 4.0.0)
GStreamer: NO
DirectShow: YES
Media Foundation: YES
Parallel framework: Concurrency
Trace: YES (with Intel ITT)
Other third-party libraries:
Intel IPP: 2019.0.0 Gold [2019.0.0]
at: C:/local/opencv-build/3rdparty/ippicv/ippicv_win/icv
Intel IPP IW: sources (2019.0.0)
at: C:/local/opencv-build/3rdparty/ippicv/ippicv_win/iw
Lapack: NO
Inference Engine: YES (2018040000 / 1.5.0)
libs: C:/local/Intel/computer_vision_sdk_2018.5.445/deployment_tools/inference_engine/lib/intel64/Release/inference_engine.lib / C:/local/Intel/computer_vision_sdk_2018.5.445/deployment_tools/inference_engine/lib/intel64/Debug/inference_engined.lib
includes: C:/local/Intel/computer_vision_sdk_2018.5.445/deployment_tools/inference_engine/include
Eigen: NO
Custom HAL: NO
Protobuf: build (3.5.1)
OpenCL: YES (no extra features)
Include path: C:/local/opencv-4.0.0/3rdparty/include/opencl/1.2
Link libraries: Dynamic load
Python 3:
Interpreter: C:/Program Files/Python36/python.exe (ver 3.6.5)
Libraries: C:/Program Files/Python36/libs/python36.lib (ver 3.6.5)
numpy: C:/Users/m/AppData/Roaming/Python/Python36/site-packages/numpy/core/include (ver 1.15.4)
packages path: C:/Program Files/Python36/Lib/site-packages
Python (for build): C:/Program Files/Python36/python.exe
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Install to: C:/local/opencv
-----------------------------------------------------------------
Configuring done
在评论中总结我们的讨论,
OpenVINO R5 于 12 月发布,但随附的 CMake 摘要显示使用的 OpenCV 版本较旧(11 月)。所以解决方案是将 OpenCV 更新到最新版本,支持从 OpenVINO R5 开始的英特尔推理引擎。
关于如何在 IE 支持下构建 OpenCV 的 Wiki:https://github.com/opencv/opencv/wiki/Intel%27s-Deep-Learning-Inference-Engine-backend
如果我尝试在启用 inferenca Engineen 的情况下构建 OpenCV 4.0.0,我会收到此错误:
1>------ Build started: Project: opencv_dnn, Configuration: Release x64 ------
1>dnn.cpp
1>C:\local\opencv-4.0.0\modules\dnn\src\dnn.cpp(1595): error C2259: 'cv::dnn::InfEngineBackendNet': cannot instantiate abstract class
1>C:\local\opencv-4.0.0\modules\dnn\src\dnn.cpp(1595): note: due to following members:
1>C:\local\opencv-4.0.0\modules\dnn\src\dnn.cpp(1595): note: 'InferenceEngine::StatusCode InferenceEngine::ICNNNetwork::serialize(const std::string &,const std::string &,InferenceEngine::ResponseDesc *) noexcept const': is abstract
1>C:\local\Intel\computer_vision_sdk_2018.5.445\deployment_tools\inference_engine\include\ie_icnn_network.hpp(190): note: see declaration of 'InferenceEngine::ICNNNetwork::serialize'
1>C:\local\opencv-4.0.0\modules\dnn\src\dnn.cpp(2556): error C2259: 'cv::dnn::InfEngineBackendNet': cannot instantiate abstract class
1>C:\local\opencv-4.0.0\modules\dnn\src\dnn.cpp(2556): note: due to following members:
1>C:\local\opencv-4.0.0\modules\dnn\src\dnn.cpp(2556): note: 'InferenceEngine::StatusCode InferenceEngine::ICNNNetwork::serialize(const std::string &,const std::string &,InferenceEngine::ResponseDesc *) noexcept const': is abstract
1>C:\local\Intel\computer_vision_sdk_2018.5.445\deployment_tools\inference_engine\include\ie_icnn_network.hpp(190): note: see declaration of 'InferenceEngine::ICNNNetwork::serialize'
1>Done building project "opencv_dnn.vcxproj" -- FAILED.
为什么我会收到这个错误?
编辑
Cmake 输出为:
Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.17134.
AVX_512F is not supported by C++ compiler
AVX512_SKX is not supported by C++ compiler
Dispatch optimization AVX512_SKX is not available, skipped
libjpeg-turbo: VERSION = 1.5.3, BUILD = opencv-4.0.0-libjpeg-turbo
Looking for Mfapi.h
Looking for Mfapi.h - found
found Intel IPP (ICV version): 2019.0.0 [2019.0.0 Gold]
at: C:/local/opencv-build/3rdparty/ippicv/ippicv_win/icv
found Intel IPP Integration Wrappers sources: 2019.0.0
at: C:/local/opencv-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)
Detected InferenceEngine: cmake package
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:/local/opencv-build/python_loader
Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx512_skx.cpp
General configuration for OpenCV 4.0.0 =====================================
Version control: unknown
Platform:
Timestamp: 2019-02-09T13:06:47Z
Host: Windows 10.0.17134 AMD64
CMake: 3.13.0-rc3
CMake generator: Visual Studio 15 2017 Win64
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
requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
SSE4_1 (7 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 (13 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/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe (ver 19.16.27026.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 /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP4 /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 /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP4 /MTd /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 /MP4 /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 /MP4 /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: IE::inference_engine 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 java_bindings_generator ml objdetect photo python3 python_bindings_generator stitching ts video videoio
Disabled: world
Disabled by dependency: -
Unavailable: java js python2
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 1.5.3-62)
WEBP: build (ver encoder: 0x020e)
PNG: build (ver 1.6.35)
TIFF: build (ver 42 - 4.0.9)
JPEG 2000: build (ver 1.900.1)
OpenEXR: build (ver 1.7.1)
HDR: YES
SUNRASTER: YES
PXM: YES
PFM: YES
Video I/O:
DC1394: NO
FFMPEG: YES (prebuilt binaries)
avcodec: YES (ver 58.35.100)
avformat: YES (ver 58.20.100)
avutil: YES (ver 56.22.100)
swscale: YES (ver 5.3.100)
avresample: YES (ver 4.0.0)
GStreamer: NO
DirectShow: YES
Media Foundation: YES
Parallel framework: Concurrency
Trace: YES (with Intel ITT)
Other third-party libraries:
Intel IPP: 2019.0.0 Gold [2019.0.0]
at: C:/local/opencv-build/3rdparty/ippicv/ippicv_win/icv
Intel IPP IW: sources (2019.0.0)
at: C:/local/opencv-build/3rdparty/ippicv/ippicv_win/iw
Lapack: NO
Inference Engine: YES (2018040000 / 1.5.0)
libs: C:/local/Intel/computer_vision_sdk_2018.5.445/deployment_tools/inference_engine/lib/intel64/Release/inference_engine.lib / C:/local/Intel/computer_vision_sdk_2018.5.445/deployment_tools/inference_engine/lib/intel64/Debug/inference_engined.lib
includes: C:/local/Intel/computer_vision_sdk_2018.5.445/deployment_tools/inference_engine/include
Eigen: NO
Custom HAL: NO
Protobuf: build (3.5.1)
OpenCL: YES (no extra features)
Include path: C:/local/opencv-4.0.0/3rdparty/include/opencl/1.2
Link libraries: Dynamic load
Python 3:
Interpreter: C:/Program Files/Python36/python.exe (ver 3.6.5)
Libraries: C:/Program Files/Python36/libs/python36.lib (ver 3.6.5)
numpy: C:/Users/m/AppData/Roaming/Python/Python36/site-packages/numpy/core/include (ver 1.15.4)
packages path: C:/Program Files/Python36/Lib/site-packages
Python (for build): C:/Program Files/Python36/python.exe
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Install to: C:/local/opencv
-----------------------------------------------------------------
Configuring done
在评论中总结我们的讨论,
OpenVINO R5 于 12 月发布,但随附的 CMake 摘要显示使用的 OpenCV 版本较旧(11 月)。所以解决方案是将 OpenCV 更新到最新版本,支持从 OpenVINO R5 开始的英特尔推理引擎。
关于如何在 IE 支持下构建 OpenCV 的 Wiki:https://github.com/opencv/opencv/wiki/Intel%27s-Deep-Learning-Inference-Engine-backend