OPENCV建筑物由于DirectX而失败

OpenCV building fails due to DirectX

本文关键字:失败 DirectX 建筑物 OPENCV      更新时间:2023-10-16

我正在遵循本指南,以在Windows 7下的QT5编译OPENCV。我正在使用:

  • cmake 3.14.3
  • OPENCV 4.1.0
  • QT 5.12.2

我按照所述配置并设置参数。然后开始汇编。它因许多类似错误而失败:

C:opencvsourcesmodulescoresrcdirectx.cpp:1055:5: error: 'cl_context' was not declared in this scope
     cl_context context = (cl_context)ctx.ptr();
     ^~~~~~~~~~
C:opencvsourcesmodulescoresrcdirectx.cpp:1055:5: note: suggested alternative: '_onexit'
     cl_context context = (cl_context)ctx.ptr();
     ^~~~~~~~~~
     _onexit
C:opencvsourcesmodulescoresrcdirectx.cpp:1057:5: error: 'cl_int' was not declared in this scope
     cl_int status = 0;
     ^~~~~~
C:opencvsourcesmodulescoresrcdirectx.cpp:1057:5: note: suggested alternative: 'lrint'
     cl_int status = 0;
     ^~~~~~
     lrint
C:opencvsourcesmodulescoresrcdirectx.cpp:1058:12: error: expected ';' before 'clImage'
     cl_mem clImage = 0;
            ^~~~~~~
C:opencvsourcesmodulescoresrcdirectx.cpp:1062:5: error: 'clImage' was not declared in this scope
     clImage = clCreateFromD3D11Texture2DNV(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 0, &status);
     ^~~~~~~
C:opencvsourcesmodulescoresrcdirectx.cpp:1062:5: note: suggested alternative: 'IplImage'
     clImage = clCreateFromD3D11Texture2DNV(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 0, &status);
     ^~~~~~~
     IplImage
C:opencvsourcesmodulescoresrcdirectx.cpp:1062:44: error: 'context' was not declared in this scope
     clImage = clCreateFromD3D11Texture2DNV(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 0, &status);
                                            ^~~~~~~
C:opencvsourcesmodulescoresrcdirectx.cpp:1062:44: note: suggested alternative: 'onexit'
     clImage = clCreateFromD3D11Texture2DNV(context, CL_MEM_WRITE_ONLY, pD3D11Texture2D, 0, &status);
                                            ^~~~~~~
                                            onexit
C:opencvsourcesmodulescoresrcdirectx.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
  • 与_openclamdblas
  • 使用_openclamdfft
  • 使用opencl_d3d11_nv
  • with_opencl_svm

了解OpenCL与DirectX有关。