为UWP构建OpenCV [英] Build OpenCV for UWP

查看:245
本文介绍了为UWP构建OpenCV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在努力为UWP构建OpenCV。

I'm currently struggling to build OpenCV for the UWP.

我已经在Google上搜索了很多,并发现了微软的OpenCV Github Repo 可以做到这一点。但是,此存储库以及我在这方面发现的几乎所有其他内容都已过时(Visual Studio 2015,旧的OpenCV版本等)。我需要使用OpenCV 3.3,因为它是一个跨平台项目,并且我不想仅由于git repo过时而重新编译其他所有内容。

I already googled quite a lot and found Microsoft's OpenCV Github Repo which tecnically should do the magic. However, this repo and pretty much everything else I found in this regard are outdated (Visual Studio 2015, old OpenCV versions etc.). I need to use OpenCV 3.3 because it's a cross platform project and I don't want to recompile everything else solely because of an outdated git repo.

有人可以解释这个过程吗?

Can anyone explain the process of building OpenCV using CMake from the official repo for the UWP?

我的第一个尝试是简单地使用Windows Dll,但是我的应用程序却对我大喊无法加载模块。然后,我尝试按照的说明构建Visual Studio Project文件的OpenCV。 此处。但是,这不会为我做这件事,因为它会引发以下错误:

My first attempt was to simply use the Windows Dlls, however my application than shouts "Failed to load module" at me. Then, I tried to build OpenCV the Visual Studio Project files as stated here and here. However, this doesn't do it for me as it throws the following error:


CMake cmake / OpenCVUtils.cmake:440( if):
,如果有给定参数:

CMake Error at cmake/OpenCVUtils.cmake:440 (if): if given arguments:

"(" "OR" "OFF" ")"

指定了未知参数
调用堆栈(最新调用优先):
CMakeLists.txt: 317(OCV_OPTION)

Unknown arguments specified Call Stack (most recent call first): CMakeLists.txt:317 (OCV_OPTION)

它还告诉我检查CMakeOutput.log,但到处都是0错误。

It also tells me to check the CMakeOutput.log but there it's 0 errors everywhere.

如果有人可以告诉我如何摆脱此错误,或者在CMake GUI中进行哪些更改以为UWP构建OpenCV,那就太好了!

If someone could tell me either how to get rid of this error or what to change in the CMake GUI to build OpenCV for UWP, that'd be great!

编辑:

我还尝试使用适用于WinRT的平台专用工具链编译OpenCV,如在platform / winrt中找到的那样。 。尽管它并没有真正改变任何东西(我什至不确定是否应该这样做),但我仍然收到无法加载Dll:找不到指定的模块。 GPPK可能是一个UWP问题,而不是OpenCV问题,也许是对的。无论如何,如果有人对此有所了解,我真的很想得到一些帮助!

I also tried to compile OpenCV with a platform specific toolchain for WinRT as found in platforms/winrt. It doesn't really change anything though (I'm not even sure if it should), I still get "Unable to load Dll: The specified module could not be found". Maybe GPPK is right in his assumption that it's more an UWP problem than an OpenCV one. Anyways, if anyone knows anything about this, I'd really love to get some help!

推荐答案

好吧,我没有得到答案了,所以我设法自己(或多或少)。

Ok, I didn't get an answer yet, so I managed to do it myself (more or less).

这是我的操作方式:

先决条件


  • Visual Studio(2017)

  • UWP SDK

  • CMake

  • 来自官方仓库的OpenCV

  • Visual Studio (2017)
  • UWP SDK
  • CMake
  • OpenCV from official repo

步骤


  1. 创建要内置UWP库的构建文件夹。

  2. 在此文件夹中启动PowerShell并执行以下命令(使用本地OpenCV路径交换C:\OpenCV): cmake -G Visual Studio 15 2017 -DCMAKE_SYSTEM_NAME = WindowsStore -DCMAKE_SYSTEM_VERS
    ION = 10.0 -DCMAKE_VS_EFFECTIVE_PLATFORMS = x86 -DBUILD_TESTS = OFF -DBUILD_PERF_TESTS = OFF C:\OpenCV

  3. 如果与我相同的错误消息(有关更多详细信息,请参阅问题),请转到在OpenCV文件夹中找到根CMakeLists.txt,并在第317行(OCV_OPTION(ENABLE_PYLINT))前面添加。这应该可以解决该问题,以再次从上方执行该命令。

  4. 确保输出声明 Windows RT支持是为Microsoft平台构建:Windows

  5. 在构建文件夹中打开OpenCV.sln。确保所有项目的类型均为 Windows应用商店或通用Windows,并两次构建ALL_BUILD项目:一次在Release配置中,一次在Debug中。然后构建INSTALL项目。

  1. Create a build folder which you want the UWP libraries to built in.
  2. Start PowerShell in this folder and execute the following command (exchange C:\OpenCV with your local OpenCV path): cmake -G "Visual Studio 15 2017" -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERS ION="10.0" -DCMAKE_VS_EFFECTIVE_PLATFORMS=x86 -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF C:\OpenCV
  3. If you get the same error message as I did (see question for more details), go to the root CMakeLists.txt in the OpenCV folder and add a # in front of line 317 (OCV_OPTION(ENABLE_PYLINT)). This should fix it, to check, execute the command from above once more.
  4. Ensure that the output claims "Windows RT support YES" and "Building for Microsoft platform: Windows".
  5. Open OpenCV.sln in the build folder. Ensure that all projects are either of type "Windows Store" or "Universal Windows" and build the ALL_BUILD Project twice: Once in Release configuration, and once in Debug. Then build the INSTALL Project.

就是这样,您应该在安装文件夹中找到已构建的Dll。第3步可能是OpenCV中的错误,有望在以后的版本中得到解决。

That's it, you should find the built Dlls in the install folder. Step 3 is probably a bug in OpenCV and will hopefully be fixed in upcoming versions.

这篇关于为UWP构建OpenCV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆