一、问题描述:
在安装好 OpenCV的依赖项后,对 OpenCV进行cmake时,提示 vtk模板错误,具体如下:
CMake Error at /usr/lib/cmake/vtk-7.1/vtkModuleAPI.cmake:120 (message):
Requested modules not available:
vtkRenderingOpenGL
Call Stack (most recent call first):
/usr/lib/cmake/vtk-7.1/VTKConfig.cmake:89 (vtk_module_config)
cmake/OpenCVDetectVTK.cmake:6 (find_package)
CMakeLists.txt:597 (include)
二、问题原因:
因为VTK7.0版本后将 vtkRenderingOpenGL改成了 vtkRenderingOpenGL2。
三、解决方法:
在opencv/cmake目录下,将OpencvDetectVTK.cmake文件中前几行的对应模块名后面加个2,具体如下:
将
# VTK 6.x components
find_package(VTK QUIET COMPONENTS vtkRenderingOpenGL vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport NO_MODULE)
改成
# VTK 6.x components
find_package(VTK QUIET COMPONENTS vtkRenderingOpenGL2 vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport NO_MODULE)