编译适用于Windows 10 IoT核心版ARM(Raspberry Pi)的OpenCV 3 [英] Compile OpenCV 3 for Windows 10 IoT Core ARM (Raspberry Pi)

查看:227
本文介绍了编译适用于Windows 10 IoT核心版ARM(Raspberry Pi)的OpenCV 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Windows OS上托管的Visual Studio为Windows 10 IoT核心版ARM(Raspberry Pi)编译OpenCV 3. *的最简单方法是什么?

我可以在其他贡献模块中使用DNN(深度神经网络)模块吗?

解决方案

我尝试为在Raspberry Pi 3上运行的Windows 10 IoT核心版(10.0.16299.0)编译OpenCV 3.4.1感到有些费力,所以我决定与我分享与社区的经验.

要求

您需要执行的所有操作是:

  • OpenCV来源(来自 Github ). opencv 用于核心功能, opencv_contrib 用于其他模块.
  • CMake-gui(此处)
  • 带有ARM工具集和Windows 10 SDK的Visual Studio.

我使用了最新的 Visual Studio 2017 (15.6.2).社区版就足够了.确保您具有必需的Visual Studio组件:

  • 适用于UWP的Windows 10 SDK(10.0.16299.0):C ++
  • 用于UWP的Visual C ++运行时
  • 用于ARM的Visual C ++编译器和库

SDK的版本显然应与目标OS平台版本匹配.今天是10.0.16299.0.

配置

启动CMake-gui.选择您的OpenCV源代码(根路径)在何处以及您要构建的位置(配置,临时和输出)在哪里存储.点击配置.

在弹出窗口中,选择 Visual Studio 15 2017 ARM 作为生成器(工具集和体系结构版本),然后选择指定交叉编译的选项" .. >

提供:

  • 操作系统: WindowsStore
  • 版本: 10.0
  • 处理器: ARM

成功的生成(可能带有一些警告)将以配置完成"结束.消息并显示制作选项.

寻找OPENCV_EXTRA_MODULES_PATH选项,并提供opencv_contrib/modules文件夹的路径.

再次点击配置.

现在,您可以选择要包含在构建中的模块. 在我的配置中,我有:

  • 启用了构建opencv-world单个库(BUILD_opencv_world)
  • 禁用构建测试和应用程序(BUILD_TESTSBUILD_PERF_TESTSBUILD_opencv_apps)
  • ((可选))启用Raspberry Pi NEON和VFP3优化(ENABLE_VPF3=ONENABLE_NEON=ON).您可以使用Cmake中的添加条目"(作为布尔值)添加它们,但是目前在处理这些选项时有些OpenCV出现问题.

我不得不禁用描述符(BUILD_opencv_line_descriptor)和显着性模块(BUILD_opencv_saliency),因为它们在使用Microsoft专用的__popcnt时遇到了问题,这在ARM平台上无法用于MS编译器.

然后,我使用了一个技巧来为Windows启用DNN模块.在/modules/dnn/CMakeList.txt 中,必须评论前三行:

#if(WINRT)
#  ocv_module_disable(dnn)
#endif()

再次

配置,然后单击生成.在Visual Studio中打开项目(.SLN).

默认项目为ALL_BUILD,这是要构建的项目.选择要构建的配置(发布或调试).请注意,对于不同的配置,生成的导入库(.lib)和dll(.dll)将具有不同的名称.

就是这样!这些库可能链接到针对UWP应用程序(C ++/CX)和ARM平台的库.

此外-您可以使用相同的过程为 x64 x86 平台构建自己的配置:再次从Cmake-gui重新启动,选择其他构建文件夹,然后在在配置的第一步,选择 Visual Studio 15 2017 x64 x86 作为生成器,然后在交叉编译选项中相应地进行处理.其余的配置过程看起来相同.

要在Windows 10 IoT核心版上进一步使用OpenCV,您可以查看Microsoft本身提供的示例,例如此处.

What is the easiest way compile OpenCV 3.* for Windows 10 IoT Core ARM (Raspberry Pi) using Visual Studio hosted on Windows OS?

Can I use DNN (Deep Neural Network) module among other contrib modules?

解决方案

I struggled a bit trying to compile OpenCV 3.4.1 for Windows 10 IoT Core (10.0.16299.0) running on Raspberry Pi 3, so I decided to share my experience with the community.

Requirements

All you need to proceed is:

  • OpenCV sources (from Github). opencv for core functionality and opencv_contrib for additional modules.
  • CMake-gui (here)
  • Visual Studio with ARM toolset and Windows 10 SDK.

I used most recent Visual Studio 2017 (15.6.2). Community Edition is enough. Make sure you have required Visual Studio components:

  • Windows 10 SDK (10.0.16299.0) for UWP: C++
  • Visual C++ runtime for UWP
  • Visual C++ compilers and libraries for ARM

Version of SDK obviously shall match target OS platform version. As of today it's 10.0.16299.0.

Configuration

Start CMake-gui. Select where are your OpenCV source codes (root path) and where you want you build (configuration, temp and output) to be stored. Click Configure.

In the popup window select Visual Studio 15 2017 ARM as a generator (toolset and architecture version) and select "Specify options for cross-compiling".

Provide:

  • Operaring System: WindowsStore
  • Version: 10.0
  • Processor: ARM

Successful generation (possibly with some warnings) shall end up with "Configuration done" message and showing make options.

Look for OPENCV_EXTRA_MODULES_PATH option and provide path to you opencv_contrib/modules folder.

Click Configure again.

Now you can select modules you wish to include in your build. In my configuration I have:

  • Enabled building opencv-world single library (BUILD_opencv_world)
  • Disable building tests and apps (BUILD_TESTS, BUILD_PERF_TESTS, BUILD_opencv_apps)
  • (Optionally) Enable Raspberry Pi NEON and VFP3 optimizations (ENABLE_VPF3=ON, ENABLE_NEON=ON). You can add them using 'add entry' in Cmake (as boolean), but there currently some OpenCV make issues processing those options.

I had to disable descriptor (BUILD_opencv_line_descriptor) and saliency modules (BUILD_opencv_saliency) cause they have problems with Microsoft specific __popcnt, which is no available on ARM platform for MS compiler.

And I used a trick to enable DNN module for Windows. In /modules/dnn/CMakeList.txt you have to comment first three lines:

#if(WINRT)
#  ocv_module_disable(dnn)
#endif()

Configure again and click Generate. Open Project (.SLN) in Visual Studio.

Default project is ALL_BUILD is this is the one to be build. Select configuration you want to build (Release or Debug). Pay attention that resulting import libraries (.lib) and dlls (.dll) will have different names for different configurations.

That's it! Those libraries may be link against UWP applications (C++/CX) and libraries for ARM platform.

Moreover - you can use the same process to build your own configuration for x64 or x86 platforms: Start over Cmake-gui again, select different build folder and in the very first step of the configuration choose Visual Studio 15 2017 x64 or x86 as your generator and then processor accordingly in the cross-compiling options. The rest of the configuration process looks the same.

To play further with OpenCV on Windows 10 IoT Core you may have a look at samples provided by Microsoft itself, e.g. here.

这篇关于编译适用于Windows 10 IoT核心版ARM(Raspberry Pi)的OpenCV 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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