readme.txt 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. Building OpenCV from Source, using CMake and Command Line
  2. =========================================================
  3. Requirements
  4. ============
  5. CMake 3.1.0 or higher
  6. Windows Phone/Store 8.1 Visual Studio 2013
  7. Windows Phone/Store 8.0 Visual Studio 2012
  8. For example, to be able to build all Windows Phone and Windows Store projects install the following:
  9. Install Visual Studio 2013 Community Edition
  10. http://go.microsoft.com/?linkid=9863608
  11. Install Visual Studio Express 2012 for Windows Desktop
  12. https://devblogs.microsoft.com/visualstudio/visual-studio-express-2012-for-windows-desktop-is-here/
  13. To create and build all Windows Phone (8.0, 8.1) and Windows Store (8.0, 8.1) Visual Studio projects
  14. ==========================================================================================
  15. cd opencv/platforms/winrt
  16. setup_winrt.bat "WP,WS" "8.0,8.1" "x86,ARM" -b
  17. If everything's fine, a few minutes later you will get the following output in the opencv/bin directory:
  18. bin
  19. install
  20. WP
  21. 8.0
  22. ARM
  23. x86
  24. 8.1
  25. ARM
  26. x86
  27. WS
  28. 8.0
  29. ARM
  30. x86
  31. 8.1
  32. ARM
  33. x86
  34. WP
  35. 8.0
  36. ARM
  37. x86
  38. 8.1
  39. ARM
  40. x86
  41. WS
  42. 8.0
  43. ARM
  44. x86
  45. 8.1
  46. ARM
  47. x86
  48. "-b" flag in the command above builds each generated solutions in both "Debug" and "Release" configurations. It also builds the predefined "INSTALL" project within generated solutions. Building it creates a separate install location that accumulates binaries and includes for specified platforms. Default location is "<ocv-src>\bin\install\".
  49. WinRT samples reference 'install' binaries and include files via "OPENCV_WINRT_INSTALL_DIR" environment variable. Please declare it and point to "<ocv-src>\bin\install\" directory to resolve references within sample applications.
  50. If you don't want to build all configurations automatically, you can omit "-b" flag and build OpenCV.sln for the particular platform you are targeting manually. Due to the current limitations of CMake, separate x86/x64/ARM projects must be generated for each platform.
  51. You can also target a single specific configuration
  52. setup_winrt.bat "WP" "8.1" "x86"
  53. Or a subset of configurations
  54. setup_winrt.bat "WP,WS" "8.1" "x86"
  55. To display the command line options for setup_winrt.bat
  56. setup_winrt.bat -h
  57. Note that x64 CMake generation support is as follows:
  58. ------------------------------
  59. Platform\Version | 8.0 | 8.1 |
  60. -----------------|-----|-----|
  61. Windows Phone | No | No |
  62. Windows Store | Yes | Yes |
  63. Note: setup_winrt.bat calls the unsigned PowerShell script with the -ExecutionPolicy Unrestricted option.
  64. CMake command line options for Windows Phone and Store
  65. ======================================================
  66. cmake [options] <path-to-source>
  67. Windows Phone 8.1 x86
  68. cmake -G "Visual Studio 12 2013" -DCMAKE_SYSTEM_NAME=WindowsPhone -DCMAKE_SYSTEM_VERSION=8.1 <path-to-source>
  69. Windows Phone 8.1 ARM
  70. cmake -G "Visual Studio 12 2013 ARM" -DCMAKE_SYSTEM_NAME=WindowsPhone -DCMAKE_SYSTEM_VERSION=8.1 <path-to-source>
  71. Windows Store 8.1 x86
  72. cmake -G "Visual Studio 12 2013" -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=8.1 <path-to-source>
  73. Windows Store 8.1 ARM
  74. cmake -G "Visual Studio 12 2013 ARM" -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=8.1 <path-to-source>
  75. Note: For Windows 8.0 Phone and Store you can specify either Visual Studio 11 2012 or Visual Studio 12 2013 as the generator
  76. Windows Phone 8.0 x86
  77. cmake -G "Visual Studio 12 2013" -DCMAKE_SYSTEM_NAME=WindowsPhone -DCMAKE_SYSTEM_VERSION=8.0 <path-to-source>
  78. Windows Phone 8.0 ARM
  79. cmake -G "Visual Studio 12 2013 ARM" -DCMAKE_SYSTEM_NAME=WindowsPhone -DCMAKE_SYSTEM_VERSION=8.0 <path-to-source>
  80. Windows Store 8.0 x86
  81. cmake -G "Visual Studio 12 2013" -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=8.0 <path-to-source>
  82. Windows Store 8.0 ARM
  83. cmake -G "Visual Studio 12 2013 ARM" -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=8.0 <path-to-source>
  84. Example
  85. ======================================================
  86. To generate Windows Phone 8.1 x86 project files in the opencv/bin dir
  87. mkdir bin
  88. cd bin
  89. cmake -G "Visual Studio 12 2013" -DCMAKE_SYSTEM_NAME=WindowsPhone -DCMAKE_SYSTEM_VERSION=8.1 ../
  90. Running tests for Windows Store
  91. ===============================
  92. 1. You might need to install this if you haven't already: http://www.microsoft.com/en-US/download/details.aspx?id=40784
  93. 2. Set OPENCV_TEST_DATA_PATH environment variable to location of opencv_extra/testdata (cloning of https://github.com/opencv/opencv_extra repo required) to get tests work correctly. Also, set OPENCV_PERF_VALIDATION_DIR environment variable in case you are planning to have place where to store performance test results and compare them with the future test runs.
  94. 3. In case you'd like to adjust some flags that are defaulted by setup_winrt script, go to "Manual build" section. Otherwise go to platforms/winrt and execute
  95. setup_winrt.bat "WS" "8.1" "x64"
  96. This will generate all files needed to build open_cv projects for selected platform in opencv\bin\<Depends on generated configuration>. Open the opencv\bin\<path to required configuration> directory and open the OpenCV.sln.
  97. 4. Set OCV solution to Release mode and build it. They should build without errors and generate executables in "bin\WS\8.1\x64\bin\Release\" (or similar path depending on the configuration)
  98. 5. Running tests:
  99. - **Accuracy:** Run opencv_test_{module}.exe via console or as usual by double clicking it. You should see output in the console window
  100. - **Performance:** Run opencv_perf_{module}.exe via console or as usual by double clicking it. You should see output in the console window. In case you'd like to write test results to file use --perf_write_validation_results=<filename> parameter; To compare current results to previous use --perf_read_validation_results=<filename>. This should read/write files from/to OPENCV_PERF_VALIDATION_DIR
  101. Manual build
  102. ============
  103. CMake interface:
  104. -----------------
  105. 1. Set CMAKE_SYSTEM_NAME to WindowsStore or WindowsPhone and CMAKE_SYSTEM_VERSION to 8.0 or 8.1
  106. 2. Set CMAKE_INSTALL_PREFIX using format "<install dir>\WS\8.1\x64" (this structure is required by samples)
  107. 3. Click "Configure" and choose required generator
  108. 4. Click "Generate"
  109. Command line:
  110. --------------
  111. 1. md bin
  112. 2. cd bin
  113. 3. Add any required parameters to this command and execute it:
  114. cmake -G "Visual Studio 12 2013 Win64" -DCMAKE_SYSTEM_NAME:String=WindowsStore -DCMAKE_SYSTEM_VERSION:String=8.1 -DCMAKE_VS_EFFECTIVE_PLATFORMS:String=x64 -DCMAKE_INSTALL_PREFIX:PATH=.\install\WS\8.1\x64\ ..
  115. Return to "Running tests for Windows Store", list item 4.