为 Windows 10 IoT Core ARM (Raspberry Pi) 编译 OpenCV 3 [英] Compile OpenCV 3 for Windows 10 IoT Core ARM (Raspberry Pi)

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

问题描述

使用托管在 Windows 操作系统上的 Visual Studio 为 Windows 10 IoT Core ARM (Raspberry Pi) 编译 OpenCV 3.* 的最简单方法是什么?

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

解决方案

我在尝试为在 Raspberry Pi 3 上运行的 Windows 10 IoT Core (10.0.16299.0) 编译 OpenCV 3.4.1 时遇到了一些困难,所以我决定分享我的社区经验.

要求

您只需要继续:

  • 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 make 问题.

    我必须禁用描述符 (BUILD_opencv_line_descriptor) 和显着性模块 (BUILD_opencv_saliency) 因为它们在 Microsoft 特定的 __popcnt 上有问题,这不是在 ARM 平台上可用于 MS 编译器.

    我使用了一个技巧来为 Windows 启用 DNN 模块.在

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

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

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

    要在 Windows 10 IoT Core 上进一步使用 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 Core ARM (Raspberry Pi) 编译 OpenCV 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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