CMake编译OpenCV,提示 Invalid character escape ‘\*‘.(已解决)

在编译OpenCV和opencv_contrib源码时,提示

CMake Error at cmake/OpenCVModule.cmake:356 (_glob_locations):
  Syntax error in cmake code at

    F:/WorkSpace/opencv-4.8.0/cmake/OpenCVModule.cmake:356

  when parsing string

    F:\WorkSpace\opencv_contrib-4.8.0\modules

  Invalid character escape '\W'.
Call Stack (most recent call first):
  cmake/OpenCVModule.cmake:408 (ocv_glob_modules)
  CMakeLists.txt:967 (ocv_register_modules)

提示“Invalid character escape '\W'.”错误,经查询,原来是OPENCV_EXTRA_MODULES_PATH的路径斜杠不对,默认的Windows路径是用反斜杠“\"

CMake编译OpenCV,提示 Invalid character escape ‘\*‘.(已解决)_第1张图片

但CMake要用正斜杠”/" 

CMake编译OpenCV,提示 Invalid character escape ‘\*‘.(已解决)_第2张图片

 将路径的斜杠改为“/”即可。

你可能感兴趣的:(OpenCVSharp学习,opencv)