在带有 Visual C++ 的 Windows 应用商店应用中使用 OpenCV [英] Using OpenCV in a Windows Store app with Visual C++

查看:15
本文介绍了在带有 Visual C++ 的 Windows 应用商店应用中使用 OpenCV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 OpenCV 库在我的 Windows 8 Store 应用程序中使用 C++/CX 进行一些图像处理.我能够使用 Visual C++ 2012 构建 OpenCV 库,但是当我打包我的应用程序并运行 Windows 应用程序认证工具包,我收到几个错误,说 OpenCV DLL 使用了一些不受支持的 Windows API.如何修复这些错误?

I am trying to use the OpenCV library for some image processing inside my Windows 8 Store app using C++/CX. I am able to build the OpenCV library using Visual C++ 2012 but when I package my app and run the Windows App Certification Kit, I get several errors saying that the OpenCV DLLs use some unsupported Windows API. How do I fix these errors?

推荐答案

OpenCV 使用 CMake 构建其源代码.下载 OpenCV 源代码后,在根文件夹中编辑文件 CMakeLists.txt 以包含以下两行:

OpenCV uses CMake to build its sources. After you have downloaded the OpenCV sources, in the root folder edit the file CMakeLists.txt to contain the following two lines:

add_definitions(-DWINAPI_FAMILY=WINAPI_FAMILY_APP)add_definitions(-D_UNICODE)

add_definitions(-DWINAPI_FAMILY=WINAPI_FAMILY_APP) add_definitions(-D_UNICODE)

在以下#if 块中:

if(WIN32 AND NOT MINGW)

if(WIN32 AND NOT MINGW)

通过这样做,您的库将只能访问 Windows 应用商店应用支持的 API.这可能意味着您将不得不修复一些构建错误(上周我尝试时并没有太多),但最终您的二进制文件将是 WACK 干净的.

By doing this your library will only have access to the API that are supported for Windows Store apps. This might mean that you will have to fix some build errors (there weren't too many when I tried last week) but eventually your binaries would be WACK clean.

但上述步骤仅适用于 OpenCV 的 x86 和 x64 版本.OpenCV 使用的 CMake 工具尚不支持 ARM 架构的 Visual C++ 2012 项目.此错误正在跟踪该问题.

But the above steps will succeed only for x86 and x64 builds of OpenCV. The CMake tool which is used by OpenCV, doesn't yet support Visual C++ 2012 projects for ARM architecture. That issue is being tracked by this bug.

现在有一个支持构建 Windows Store 和 Phone 应用程序(8.0 和 8.1)的 CMake 端口.在此处查看详细信息:http://cmakems.codeplex.com/

There is now a port of CMake that support building Windows Store and Phone apps (both 8.0 and 8.1). See details here: http://cmakems.codeplex.com/

以下视频展示了 OpenCV 在使用 C++ 编写的 Windows 10 通用应用程序中的运行情况:http://channel9.msdn.com/Events/Build/2015/3-82

The below video shows OpenCV working in a Windows 10 Universal app written using C++: http://channel9.msdn.com/Events/Build/2015/3-82

这篇关于在带有 Visual C++ 的 Windows 应用商店应用中使用 OpenCV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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