How to build viz module with VTK 9.0.1?

asked 2020-07-30 20:57:02 -0500

Luckygg gravatar image

updated 2020-07-30 20:58:10 -0500

Hi all.

I would like to build OpenCV with viz module using VTK 9.0.1.


  1. OS: Windows 10 x64
  2. IDE: Visual Studio 2015
  3. SDK: OpenCV 4.4.0, VTK 9.0.1
  4. CMake: 3.17.0-rc1

I referred this link:

I tried as below procedure :


  1. Download VTK-9.0.1.tar.gz file and unzip to 'vtk_sources' folder.
  2. Create 'vtk_bin' folder.
  3. Run CMake program as a administrator and set the 'vtk_sources' path to 'source code', 'vtk_bin' path to 'binaries'.
  4. Click the 'Configure' button and select 'Visual Studio 2015', 'x64'.
  5. Select VTK default option and click the 'Generate' button.
  6. Run VTK.sln in the vtk_bin folder as a administrator.
  7. Build 'ALL_BUILD' and 'INSTALL'.
  8. Succeeded to create a library and it works well.


  1. Download opencv-4.4.0-vc14_vc15.exe file and run.
  2. Copy the 'sources' file to 'opencv_sources' folder.
  3. Create 'opencv_bin' folder.
  4. Run CMake program as a administrator and set the 'opencv_sources' path to 'source code', 'opencv_bin' path to 'binaries'.
  5. Click the 'Configure' button and select 'Visual Studio 2015', 'x64'.
  6. Set the VTK_DIR to 'vtk_bin' folder.
  7. Check the 'WITH_VTK'.
  8. Uncheck the 'BUILD_opencv_world'.
  9. Click the 'Generate' button.
  10. Run OpenCV.sln in the opencv_bin folder as a administrator.
  11. Build 'ALL_BUILD' and 'INSTALL'.
  12. Succeeded to create a library and it works well.
  13. But 'include/opencv2/' has no viz.hpp file. I can't find the 'viz' file.

I have been trying to build the OpenCV with viz for a week. But I couldn't find any solution.

Could you please help me?

Thank you.

edit retag flag offensive close merge delete


the viz module is from opencv_contrib, did you miss that ?


berak gravatar imageberak ( 2020-07-31 01:26:09 -0500 )edit

I found that I missed opencv_contrib. and I'm trying to build the OpenCV 4.4.0 with VTK 9.0.1 and opencv_contrib 4.4.0. But the error occurred.

CMake Error at C:/Users/tech/Downloads/vtk_bin/lib/cmake/vtk-9.0/vtkModule.cmake:2955 (get_property):
  get_property could not find TARGET opencv_viz.  Perhaps it has not yet been
Call Stack (most recent call first):
  C:/Users/tech/Downloads/opencv_contrib-4.4.0/modules/viz/CMakeLists.txt:43 (vtk_module_autoinit)
  modules/world/CMakeLists.txt:13 (include)
  modules/world/CMakeLists.txt:32 (include_one_module)

CMake Error at C:/Users/tech/Downloads/vtk_bin/lib/cmake/vtk-9.0/vtkModule.cmake:2962 (target_compile_definitions):
  Cannot specify compile definitions for target "opencv_viz" which
Luckygg gravatar imageLuckygg ( 2020-07-31 02:35:34 -0500 )edit

^^ can you edit your question, and put errors there, please ? (comments are far too limited for this task)

berak gravatar imageberak ( 2020-07-31 02:41:05 -0500 )edit

I'm facing the same issue. Please post an answer if found. Or if previous version is compatible ( either earlier version of opencv or earlier version version of vtk) whichever is closest please let me know,

astropiu gravatar imageastropiu ( 2020-10-12 05:01:14 -0500 )edit
sturkmen gravatar imagesturkmen ( 2020-10-12 05:20:32 -0500 )edit