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?
相关问题
- How to get the background from multiple images by
- how to call a C++ dll from C# windows application
- efficiently calling unmanaged method taking unmana
- Try to load image with Highgui.imread (OpenCV + An
- CV2 Image Error: error: (-215:Assertion failed) !s
相关文章
- Visual Studio Hangs on Loading UI Library
- opencv fails to build with ipp support enabled
- “Csc.exe” exited with code -1073741819
- C++: Callback typedefs with __stdcall in MSVC
- Code completion is not working for OpenCV and Pyth
- New Windows Application - What language?
- Is it possible to check whether you are building f
- Which VC++ redistributable package to choose (x86
I've managed to build a subset of OpenCV for ARM.
I started by getting the subset I was interested in building for Windows Store applications in x86. After pointing CMake at a source download of OpenCV, I used the Visual Studio 11 generator to configure an x86 project. I added a new build option within CMake called TARGET_METRO, and used this to further configure the other projects.
This allowed me to turn off several 3rd-party components I did not want to build, eg:
I turned off WITH_VIDEOINPUT, BUILD_PERF_TESTS, and BUILD_TESTS in this fashion. I also added the definitions mentioned by Raman when TARGET_METRO was on:
I then proceeded to generate the x86 (Visual Studio 11) version of the project with CMake and started attempting to build the project. You will run into a number of issues, most of which relate to missing APIs in WinRT. Most of these are mechanical changes (for example, swapping out
InitializeCriticalSection
forInitializeCriticalSectionEx
). I wrapped these changes under#if WINAPI_FAMILY == WINAPI_FAMILY_APP
so that it would not impact the non-TARGET_METRO build.When it came time to build for ARM, what I did was launch CMake and use the Visual Studio 11 generator to generate a new project (under a directory named 'ARM') and then began manually editing the resulting project files.
The major changes you need to make are:
<AppContainerApplication>true</AppContainerApplication>
to the Globals propertygroupAdd the following at the project level (for each project you want to build for ARM):
Remove "/machine:X86 " from Link: Additional Options (if it is in there)
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)
in the following #if block:
if(WIN32 AND NOT MINGW)
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.
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.
Update
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/
Second Update
The below video shows OpenCV working in a Windows 10 Universal app written using C++: http://channel9.msdn.com/Events/Build/2015/3-82
We are working on enabling OpenCV with the new Phone and Store build of CMake. In the meantime have you looked at http://github.com/msopentech/openCV. This has instructions on building OpenCV for WinRT.
Disclaimer: I am 100% new to OpenCV as a library and just started to explore this today when I found some sample apps using OpenCV around Azure Cognitive Vision samples.
My only goal was to even see if "OpenCV was supported on UWP and works with ARM". I read a bunch of posts and blogs that were around since 2015+ and they were making me think this was not possible to get working.
Then I found this sample: https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CameraOpenCV
And can confirm it works for my basic test, you can see my video here of ARM Pi 2 running UWP app, using the OpenCV library: https://twitter.com/LyalinDotCom/status/982830053355470848
not saying that this means all of OpenCV will just work but at least this test was a good sign and i wanted to share my early results here.