Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows 10 CMake | OPENCV_EXTRA_MODULES_PATH | Bug #11655

Open
ashuezy opened this issue Jun 1, 2018 · 18 comments
Open

Windows 10 CMake | OPENCV_EXTRA_MODULES_PATH | Bug #11655

ashuezy opened this issue Jun 1, 2018 · 18 comments

Comments

@ashuezy
Copy link

ashuezy commented Jun 1, 2018

  • OpenCV => Latest Github
  • Operating System / Platform => Windows 64 Bit
  • Compiler => Visual Studio 2015
CMake Error at cmake/OpenCVModule.cmake:368 (_glob_locations):
  Syntax error in cmake code at

    E:/opencv_github/opencv/cmake/OpenCVModule.cmake:368

  when parsing string

    E:\opencv_github\opencv_contrib\modules

  Invalid character escape '\o'.
Call Stack (most recent call first):
  modules/CMakeLists.txt:7 (ocv_glob_modules)

This error is only generated when i set OPENCV_EXTRA_MODULES_PATH,
I have set the path to the modules folder after taking checkout of opencv_contrib.

image

@alalek
Copy link
Member

alalek commented Jun 1, 2018

Use forward slash ('/') in paths, even on Windows.

@ashuezy
Copy link
Author

ashuezy commented Jun 1, 2018

set(the_description "Face recognition etc")
ocv_define_module(face opencv_core
    opencv_imgproc
    opencv_objdetect
    opencv_video     # estimateRigidTransform() (trainFacemark)
    opencv_photo     # seamlessClone() (face_swap sample)
    WRAP python java
)
# NOTE: objdetect module is needed for one of the samples

set(__commit_hash "8afa57abc8229d611c4937165d20e2a2d9fc5a12")
set(__file_hash "7505c44ca4eb54b4ab1e4777cb96ac05")
ocv_download(
    FILENAME face_landmark_model.dat
    HASH ${__file_hash}
    URL
      "${OPENCV_FACE_ALIGNMENT_URL}"
      "$ENV{OPENCV_FACE_ALIGNMENT_URL}"
      "https://raw.githubusercontent.com/opencv/opencv_3rdparty/${__commit_hash}/"
    DESTINATION_DIR "${CMAKE_BINARY_DIR}/${OPENCV_TEST_DATA_INSTALL_PATH}/cv/face/"
    ID "data"
    RELATIVE_URL
    STATUS res
)
if(NOT res)
  message(WARNING "Face: Can't get model file for face alignment.")
endif()

The only slash 'o' is the url.

@alalek
Copy link
Member

alalek commented Jun 1, 2018

Problem is here:

E:\opencv_github\opencv_contrib\modules
E: => \o <= pencv_github => \o <= pencv_contrib\modules

@alalek
Copy link
Member

alalek commented Jun 1, 2018

BTW, What is CMake version used?

@ashuezy
Copy link
Author

ashuezy commented Jun 1, 2018

@alalek
3.10.0

@kinchungwong
Copy link
Contributor

Unfortunately, CMake places this responsibility on the CMake script maintainers. See TO_CMAKE_PATH and TO_NATIVE_PATH

https://stackoverflow.com/questions/47910256/cmake-how-to-normalize-paths
https://stackoverflow.com/questions/32585927/proper-way-to-use-platform-specifc-spearators-in-cmake

@ashuezy
Copy link
Author

ashuezy commented Jun 1, 2018

@kinchungwong
What i can do i solve this on my system ?

@alalek
Copy link
Member

alalek commented Jun 1, 2018

As workaround try to run cmake with '/' in paths:

cmake -DOPENCV_EXTRA_MODULES_PATH=E:/opencv_github/opencv_contrib/modules ...

@ashuezy
Copy link
Author

ashuezy commented Jun 1, 2018

@alalek

I am using windows.

@alalek
Copy link
Member

alalek commented Jun 1, 2018

Unfortunately we don't observe these problems with Windows:
http://pullrequest.opencv.org/buildbot/builders/3_4-contrib-win64-vc14/builds/14/steps/cmake/logs/stdio

Message blames on this line:
https://github.com/opencv/opencv/blame/0f298a42032798d2d83017030621fcba885a3372/cmake/OpenCVModule.cmake#L368

with "syntax error", but syntax itself is correct.

Related CMake bug: https://gitlab.kitware.com/cmake/cmake/issues/17382
It is closed, but their "fix" doesn't fix problem with CMake's "syntax error".
Issue's reproducer just ignored and still reproducible with at least CMake 3.10.2.

@ashuezy
Copy link
Author

ashuezy commented Jun 2, 2018

@alalek
Is there ANY solution ,.. get around for the time being ?

@alalek
Copy link
Member

alalek commented Jun 2, 2018

Workaround: #11655 (comment)

I can't propose something else because I can't reproduce the problem on machines from my side.

@csukuangfj
Copy link
Contributor

@ashuezy
/ is also supported on the Windows platform.

@mworchel
Copy link
Contributor

mworchel commented Jun 5, 2018

I just compiled the latest OpenCV version on Windows 10 64-bit with contributor modules, it works fine.
@ashuezy You maybe misunderstood what the others meant: You have to replace every \ in the path with a /.

@rkachach
Copy link

rkachach commented Dec 21, 2018

I got the same error using an incorrect path for modules. Just in case somebody runs in the same problem ..

@seaweedseed
Copy link

Though I got the same error at first, after changing my directory(which contains "opencv" and "opencv_contrib") from D: to C: , it worked fine. I don't know why...

If I have any mistakes, just tell me plz.

  • opencv => 4.0
  • opencv_contrib => 4.0.0
  • Operating System / Platform => Windows 64 Bit
  • Compiler => Visual Studio 15 2017

@marianojj
Copy link

I was able to solve this problem by inverting the address bars of the folder
C:\Users\MyUser\OpenCv\opencv_contrib-4.3.0\modules to C:/Users/MyUser/OpenCv/opencv_contrib-4.3.0/modules
If you are using cmake gui you can navigate to the folder using
the option (...) in the space reserved for the value in OPENCV_EXTRA_MODULES_PATH, this brings the bars in the right format for the cmake.
I hope this helps, it worked for me.

@Ilan-peled
Copy link

Any mistake in the path gives this error. My mistake was:
I entered C:/Users/MyUser/OpenCv/opencv_contrib-4.3.0/
instead of C:/Users/MyUser/OpenCv/opencv_contrib-4.3.0/modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants