c++ - 由于 DirectX,OpenCV 构建失败

标签 c++ windows opencv mingw directx

我正在关注这个 guide在 Windows 7 下为 Qt5 编译 OpenCV。 我正在使用:

  • CMake 3.14.3
  • OpenCV 4.1.0
  • Qt 5.12.2

我按照说明配置和设置了参数。然后开始编译。它失败并出现许多类似的错误:

C:\opencv\sources\modules\core\src\directx.cpp:1055:5: error: 'cl_context' was not declared in this scope
     cl_context context = (cl_context)ctx.ptr();
     ^~~~~~~~~~
C:\opencv\sources\modules\core\src\directx.cpp:1055:5: note: suggested alternative: '_onexit'
     cl_context context = (cl_context)ctx.ptr();
     ^~~~~~~~~~
     _onexit
C:\opencv\sources\modules\core\src\directx.cpp:1057:5: error: 'cl_int' was not declared in this scope
     cl_int status = 0;
     ^~~~~~
C:\opencv\sources\modules\core\src\directx.cpp:1057:5: note: suggested alternative: 'lrint'
     cl_int status = 0;
     ^~~~~~
     lrint
C:\opencv\sources\modules\core\src\directx.cpp:1058:12: error: expected ';' before 'clImage'
     cl_mem clImage = 0;
            ^~~~~~~
C:\opencv\sources\modules\core\src\directx.cpp:1062:5: error: 'clImage' was not declared in this scope
     clImage = clCreateFromD3D11Texture2DNV(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 0, &status);
     ^~~~~~~
C:\opencv\sources\modules\core\src\directx.cpp:1062:5: note: suggested alternative: 'IplImage'
     clImage = clCreateFromD3D11Texture2DNV(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 0, &status);
     ^~~~~~~
     IplImage
C:\opencv\sources\modules\core\src\directx.cpp:1062:44: error: 'context' was not declared in this scope
     clImage = clCreateFromD3D11Texture2DNV(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 0, &status);
                                            ^~~~~~~
C:\opencv\sources\modules\core\src\directx.cpp:1062:44: note: suggested alternative: 'onexit'
     clImage = clCreateFromD3D11Texture2DNV(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 0, &status);
                                            ^~~~~~~
                                            onexit
C:\opencv\sources\modules\core\src\directx.cpp:1062:53: error: 'CL_MEM_WRITE_ONLY' was not declared in this scope
     clImage = clCreateFromD3D11Texture2DNV(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 0, &status);

我在 CMake 中禁用了 WITH_DIRECTX 标志,然后:

  1. 配置
  2. 生成
  3. mingw32-make clean
  4. mingw32-make -j 8

但是错误仍然存​​在。 我还必须做些什么来解决这个问题?

最佳答案

要禁用 directx,我还必须关闭所有与 OpenCL 相关的项目:

  • OPENCL_FOUND
  • OPENCV_DNN_OPENCL
  • WITH_OPENCL
  • WITH_OPENCLAMDBLAS
  • WITH_OPENCLAMDFFT
  • 使用 OPENCL_D3D11_NV
  • WITH_OPENCL_SVM

要理解 OpenCL 与 DirectX 的关系并不是那么简单。

关于c++ - 由于 DirectX,OpenCV 构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56019425/

相关文章:

c++ - QT:来自多个旋转框的项目列表

C++ std::function 从派生类绑定(bind)

无法使用 MinGW 编译 C 代码

windows - 为什么 sort 命令在法语语言环境中对 "œ"和 "oe"进行无差别排序?

java - 打开 cmd 并等待用户在 cmd 中输入和来自 java 的 exec 命令

python-3.x - 将检测到的OpenCV人脸复制到新图像

c++ - 开源 C++ 扫描库

python - GDB Python API : Doesn't . parse_and_eval() 使 .cast() 和 .dereference() 变得多余?

c++ - 将bgr转换为ycbcr并在opencv中分离 channel

python - 去除图像中的倾斜水平线