Incubator-mxnet: OpenCV 4.0 is currently not support on win10

Created on 11 Mar 2019  ·  10Comments  ·  Source: apache/incubator-mxnet

I try to build mxnet on win10_64. With the latest mxnet source code, and vs2017(changed to v14) cuda(10.1)+cudnn+mkl+mkldnn+opencv4(prebuilt), then it raises an error after compiling about 15 minutes.

incomplete type is not allowed  mxnet   c:\opencv\build\include\opencv2\core\cvstd_wrapper.hpp  45

But everything is ok with opencv3.4.4(prebuilt).

Build Windows

All 10 comments

Hey, this is the MXNet Label Bot.
Thank you for submitting the issue! I will try and suggest some labels so that the appropriate MXNet community members can help resolve it.
Here are my recommended labels: Build

Could you please provide the context of error message, and the code of c:\opencv\build\include\opencv2\core\cvstd_wrapper.hpp 45?

@wkcn,for context of error message, the blew is the total errors:

严重性 代码  说明  项目  文件  行   禁止显示状态
错误  MSB3721 命令“"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin\nvcc.exe" -gencode=arch=compute_50,code=\"sm_50,compute_50\" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64" -x cu  -I"C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.2.190\windows\mkl\include" -IC:\mxnet\3rdparty\mkldnn\include -IC:\mxnet\include -IC:\mxnet\src -IC:\mxnet\3rdparty\mshadow -IC:\mxnet\3rdparty\cub -IC:\mxnet\3rdparty\tvm\nnvm\include -IC:\mxnet\3rdparty\tvm\include -I"C:\mxnet\3rdparty\dmlc-core\include" -IC:\mxnet\3rdparty\dlpack\include -IC:\opencv4\build\include -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include"     --keep-dir x64\Release -maxrregcount=0  --machine 64 --compile -cudart static -Xcompiler="/MP /bigobj -openmp -Ob2 -Gy"    -DNDEBUG -DWIN32_LEAN_AND_MEAN -DDMLC_USE_CXX11 -DMSHADOW_IN_CXX11 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -DMXNET_EXPORTS -DNNVM_EXPORTS -DDMLC_STRICT_CXX11 -DNOMINMAX -DUSE_MKL=1 -DCUB_MKL=1 -DMXNET_USE_MKLDNN=1 -DMSHADOW_USE_CUDA=1 -DMXNET_USE_NCCL=0 -DUSE_MKL -DUSE_CBLAS -DMSHADOW_USE_CBLAS=0 -DMSHADOW_USE_MKL=1 -DMXNET_USE_BLAS_MKL=1 -DMXNET_USE_OPENCV=1 -DMXNET_USE_OPENMP=1 -DMXNET_USE_LAPACK=1 -DUSE_CUDNN -DMSHADOW_USE_CUDNN=1 -DMXNET_ENABLE_CUDA_RTC=1 -DMXNET_USE_CUDA=1 -D"CMAKE_INTDIR=\"Release\"" -Dmxnet_EXPORTS -DNDEBUG -DWIN32_LEAN_AND_MEAN -DDMLC_USE_CXX11 -DMSHADOW_IN_CXX11 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -DMXNET_EXPORTS -DNNVM_EXPORTS -DDMLC_STRICT_CXX11 -DNOMINMAX -DUSE_MKL=1 -DCUB_MKL=1 -DMXNET_USE_MKLDNN=1 -DMSHADOW_USE_CUDA=1 -DMXNET_USE_NCCL=0 -DUSE_MKL -DUSE_CBLAS -DMSHADOW_USE_CBLAS=0 -DMSHADOW_USE_MKL=1 -DMXNET_USE_BLAS_MKL=1 -DMXNET_USE_OPENCV=1 -DMXNET_USE_OPENMP=1 -DMXNET_USE_LAPACK=1 -DUSE_CUDNN -DMSHADOW_USE_CUDNN=1 -DMXNET_ENABLE_CUDA_RTC=1 -DMXNET_USE_CUDA=1 -D"CMAKE_INTDIR=\"Release\"" -Dmxnet_EXPORTS -D_WINDLL -D_MBCS -Xcompiler "/EHsc /W1 /nologo /O2 /Fdmxnet.dir\Release\vc140.pdb /FS /Zi  /MT " -o mxnet.dir\Release\/src/operator/image/resize.cu.obj "C:\mxnet\src\operator\image\resize.cu"”已退出,返回代码为 1。    mxnet   C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations\CUDA 10.1.targets    757 
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误  MSB3721 命令“"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin\nvcc.exe" -gencode=arch=compute_50,code=\"sm_50,compute_50\" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64" -x cu  -I"C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.2.190\windows\mkl\include" -IC:\mxnet\3rdparty\mkldnn\include -IC:\mxnet\include -IC:\mxnet\src -IC:\mxnet\3rdparty\mshadow -IC:\mxnet\3rdparty\cub -IC:\mxnet\3rdparty\tvm\nnvm\include -IC:\mxnet\3rdparty\tvm\include -I"C:\mxnet\3rdparty\dmlc-core\include" -IC:\mxnet\3rdparty\dlpack\include -IC:\opencv4\build\include -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include"     --keep-dir x64\Release -maxrregcount=0  --machine 64 --compile -cudart static -Xcompiler="/MP /bigobj -openmp -Ob2 -Gy"    -DNDEBUG -DWIN32_LEAN_AND_MEAN -DDMLC_USE_CXX11 -DMSHADOW_IN_CXX11 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -DMXNET_EXPORTS -DNNVM_EXPORTS -DDMLC_STRICT_CXX11 -DNOMINMAX -DUSE_MKL=1 -DCUB_MKL=1 -DMXNET_USE_MKLDNN=1 -DMSHADOW_USE_CUDA=1 -DMXNET_USE_NCCL=0 -DUSE_MKL -DUSE_CBLAS -DMSHADOW_USE_CBLAS=0 -DMSHADOW_USE_MKL=1 -DMXNET_USE_BLAS_MKL=1 -DMXNET_USE_OPENCV=1 -DMXNET_USE_OPENMP=1 -DMXNET_USE_LAPACK=1 -DUSE_CUDNN -DMSHADOW_USE_CUDNN=1 -DMXNET_ENABLE_CUDA_RTC=1 -DMXNET_USE_CUDA=1 -D"CMAKE_INTDIR=\"Release\"" -Dmxnet_EXPORTS -DNDEBUG -DWIN32_LEAN_AND_MEAN -DDMLC_USE_CXX11 -DMSHADOW_IN_CXX11 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -DMXNET_EXPORTS -DNNVM_EXPORTS -DDMLC_STRICT_CXX11 -DNOMINMAX -DUSE_MKL=1 -DCUB_MKL=1 -DMXNET_USE_MKLDNN=1 -DMSHADOW_USE_CUDA=1 -DMXNET_USE_NCCL=0 -DUSE_MKL -DUSE_CBLAS -DMSHADOW_USE_CBLAS=0 -DMSHADOW_USE_MKL=1 -DMXNET_USE_BLAS_MKL=1 -DMXNET_USE_OPENCV=1 -DMXNET_USE_OPENMP=1 -DMXNET_USE_LAPACK=1 -DUSE_CUDNN -DMSHADOW_USE_CUDNN=1 -DMXNET_ENABLE_CUDA_RTC=1 -DMXNET_USE_CUDA=1 -D"CMAKE_INTDIR=\"Release\"" -Dmxnet_EXPORTS -D_WINDLL -D_MBCS -Xcompiler "/EHsc /W1 /nologo /O2 /Fdmxnet.dir\Release\vc140.pdb /FS /Zi  /MT " -o mxnet.dir\Release\/src/operator/image/image_random.cu.obj "C:\mxnet\src\operator\image\image_random.cu"”已退出,返回代码为 1。    mxnet   C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations\CUDA 10.1.targets    757 
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      incomplete type is not allowed  mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 45  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      name followed by "::" must be a class or namespace name mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 52  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  
错误      template instantiation resulted in unexpected function type of "std::true_type (std::integral_constant<__nv_bool, false> *)" (the meaning of a name may have changed since the template declaration -- the type of the template is "std::true_type (std::is_same<std::decay<decltype((<expression>))>::type, void>::type *)")   mxnet   c:\opencv4\build\include\opencv2\core\cvstd_wrapper.hpp 49  

for code of cvstd_wrapper.hpp in OPENCV4.0:

// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.

#ifndef OPENCV_CORE_CVSTD_WRAPPER_HPP
#define OPENCV_CORE_CVSTD_WRAPPER_HPP

#include "opencv2/core/cvdef.h"

#include <string>
#include <memory>  // std::shared_ptr
#include <type_traits>  // std::enable_if

namespace cv {

using std::nullptr_t;

//! @addtogroup core_basic
//! @{

#ifdef CV_DOXYGEN

template <typename _Tp> using Ptr = std::shared_ptr<_Tp>;  // In ideal world it should look like this, but we need some compatibility workarounds below

template<typename _Tp, typename ... A1> static inline
Ptr<_Tp> makePtr(const A1&... a1) { return std::make_shared<_Tp>(a1...); }

#else  // cv::Ptr with compatibility workarounds

// It should be defined for C-API types only.
// C++ types should use regular "delete" operator.
template<typename Y> struct DefaultDeleter;
#if 0
{
    void operator()(Y* p) const;
};
#endif

namespace sfinae {
template<typename C, typename Ret, typename... Args>
struct has_parenthesis_operator
{
private:
    template<typename T>
    static CV_CONSTEXPR std::true_type check(typename std::is_same<typename std::decay<decltype(std::declval<T>().operator()(std::declval<Args>()...))>::type, Ret>::type*);

    template<typename> static CV_CONSTEXPR std::false_type check(...);

    typedef decltype(check<C>(0)) type;

public:
    static CV_CONSTEXPR bool value = type::value;
};
} // namespace sfinae

template <typename T, typename = void>
struct has_custom_delete
        : public std::false_type {};

template <typename T>
struct has_custom_delete<T, typename std::enable_if< sfinae::has_parenthesis_operator<DefaultDeleter<T>, void, T*>::value >::type >
        : public std::true_type {};


template<typename T>
struct Ptr : public std::shared_ptr<T>
{
#if 0
    using std::shared_ptr<T>::shared_ptr;  // GCC 5.x can't handle this
#else
    inline Ptr() CV_NOEXCEPT : std::shared_ptr<T>() {}
    inline Ptr(nullptr_t) CV_NOEXCEPT : std::shared_ptr<T>(nullptr) {}
    template<typename Y, typename D> inline Ptr(Y* p, D d) : std::shared_ptr<T>(p, d) {}
    template<typename D> inline Ptr(nullptr_t, D d) : std::shared_ptr<T>(nullptr, d) {}

    template<typename Y> inline Ptr(const Ptr<Y>& r, T* ptr) CV_NOEXCEPT : std::shared_ptr<T>(r, ptr) {}

    inline Ptr(const Ptr<T>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {}
    inline Ptr(Ptr<T>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {}

    template<typename Y> inline Ptr(const Ptr<Y>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {}
    template<typename Y> inline Ptr(Ptr<Y>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {}
#endif
    inline Ptr(const std::shared_ptr<T>& o) CV_NOEXCEPT : std::shared_ptr<T>(o) {}
    inline Ptr(std::shared_ptr<T>&& o) CV_NOEXCEPT : std::shared_ptr<T>(std::move(o)) {}

    // Overload with custom DefaultDeleter: Ptr<IplImage>(...)
    template<typename Y>
    inline Ptr(const std::true_type&, Y* ptr) : std::shared_ptr<T>(ptr, DefaultDeleter<Y>()) {}

    // Overload without custom deleter: Ptr<std::string>(...);
    template<typename Y>
    inline Ptr(const std::false_type&, Y* ptr) : std::shared_ptr<T>(ptr) {}

    template<typename Y = T>
    inline Ptr(Y* ptr) : Ptr(has_custom_delete<Y>(), ptr) {}

    // Overload with custom DefaultDeleter: Ptr<IplImage>(...)
    template<typename Y>
    inline void reset(const std::true_type&, Y* ptr) { std::shared_ptr<T>::reset(ptr, DefaultDeleter<Y>()); }

    // Overload without custom deleter: Ptr<std::string>(...);
    template<typename Y>
    inline void reset(const std::false_type&, Y* ptr) { std::shared_ptr<T>::reset(ptr); }

    template<typename Y>
    inline void reset(Y* ptr) { Ptr<T>::reset(has_custom_delete<Y>(), ptr); }

    template<class Y, class Deleter>
    void reset(Y* ptr, Deleter d) { std::shared_ptr<T>::reset(ptr, d); }

    void reset() CV_NOEXCEPT { std::shared_ptr<T>::reset(); }

    Ptr& operator=(const Ptr& o) { std::shared_ptr<T>::operator =(o); return *this; }
    template<typename Y> inline Ptr& operator=(const Ptr<Y>& o) { std::shared_ptr<T>::operator =(o); return *this; }

    T* operator->() const CV_NOEXCEPT { return std::shared_ptr<T>::get();}
    typename std::add_lvalue_reference<T>::type operator*() const CV_NOEXCEPT { return *std::shared_ptr<T>::get(); }

    // OpenCV 3.x methods (not a part of standart C++ library)
    inline void release() { std::shared_ptr<T>::reset(); }
    inline operator T* () const { return std::shared_ptr<T>::get(); }
    inline bool empty() const { return std::shared_ptr<T>::get() == nullptr; }

    template<typename Y> inline
    Ptr<Y> staticCast() const CV_NOEXCEPT { return std::static_pointer_cast<Y>(*this); }

    template<typename Y> inline
    Ptr<Y> constCast() const CV_NOEXCEPT { return std::const_pointer_cast<Y>(*this); }

    template<typename Y> inline
    Ptr<Y> dynamicCast() const CV_NOEXCEPT { return std::dynamic_pointer_cast<Y>(*this); }
};

template<typename _Tp, typename ... A1> static inline
Ptr<_Tp> makePtr(const A1&... a1)
{
    static_assert( !has_custom_delete<_Tp>::value, "Can't use this makePtr with custom DefaultDeleter");
    return (Ptr<_Tp>)std::make_shared<_Tp>(a1...);
}

#endif // CV_DOXYGEN

//! @} core_basic
} // cv

#endif //OPENCV_CORE_CVSTD_WRAPPER_HPP

the code at line 45 is

 static CV_CONSTEXPR std::true_type check(typename std::is_same<typename std::decay<decltype(std::declval<T>().operator()(std::declval<Args>()...))>::type, Ret>::type*);

@wkcn,but how to deal with it with visual studio, since the whole comipling shoud be done under v14.

Sorry that I do not know, and I do not have VS to reproduce it. Maybe someone could help you.

This is a problem with opencv.
look like it has been fixed at 4.0.1.upgraded to opencv 4.0.1 and try again.
upgraded opencv to master and try again.

@yajiedesign , oh~seems I have to build opencv from scratch.

@yajiedesign,I tried to build OPENCV4.0.1 first, indeed, now libmxnet.dll is built successfully , But Importing mxnet in python, it failed with opencv_world401.dll:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\ProgramData\Anaconda3\lib\site-packages\mxnet\__init__.py", line 24, in <module>
    from .context import Context, current_context, cpu, gpu, cpu_pinned
  File "C:\ProgramData\Anaconda3\lib\site-packages\mxnet\context.py", line 24, in <module>
    from .base import classproperty, with_metaclass, _MXClassPropertyMetaClass
  File "C:\ProgramData\Anaconda3\lib\site-packages\mxnet\base.py", line 213, in <module>
    _LIB = _load_lib()
  File "C:\ProgramData\Anaconda3\lib\site-packages\mxnet\base.py", line 204, in _load_lib
    lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL)
  File "C:\ProgramData\Anaconda3\lib\ctypes\__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] 找不到指定的模块。

Interesting, when I put opencv_world344.dll with libmxnet.dll, it is working, though libmxnet.dll is compiled with opencv 4.0.1.

Updating:
I tried again, it is my fault that I didn't build opencv dll correctly. Now opencv_world401.dll is workable with mxnet in python.

@dbsxdbsx I am closing this issue because it seems like you were able to successfully build OpenCV 4.0 for windows. Please reopen if I'm closing this in error.

Was this page helpful?
0 / 5 - 0 ratings