We can't get Wikitude working in a Xamarin crossplatform project (Android and iOS), which also uses OpenCV.
The Setup
Xamarin crossplatform project using MvvmCross with the following setup:
- Core-project, PCL providing view models, business logic and platform-agnostic logic in general.
- OpenCV.Droid, bindings project providing OpenCV to the Android part.
- Android Library (AAR), created from the official OpenCV SDK for Android.
- OpenCV.iOS, bindings project providing OpenCV to the iOS part using P/Invoke.
- Own static library project.
- Includes the static library from the official OpenCV SDK for iOS, which is just an Apple Framework (combining the static library and headers).
- Exposes OpenCV functionality via own API to minimize the amount of marshaling code.
- UI.Droid, Android platform project providing views and platform specific logic.
- UI.iOS, iOS platform project providing views and platform specific logic.
Our ARchitectWorld uses Object Tracking and could successfully be tested in the Wikitude examples contained in the Xamarin Component for both Android and iOS.
The Problem
When starting the ARchitectWorld in our iOS project, the world is loaded and we receive the onLoaded
-callback when creating the TargetCollectionResource
, as well as the onTargetsLoaded
-callback when creating the ObjectTracker
. So far, the behavior is the same in Wikitude's sample project, as well as our project.
The problem is, that the same object using the same WTO-file is not being recognized in our project, while it's working very well in the sample project.
The Investigation
When that problem occurred, we streamlined the logic in the ViewController which handles the ARchitectWorld, to rule out problems in our code there.
We then investigated our project by adding the ARchitectWorld to different commits in our repo's history, which we deemed critical changes and found commits, were object tracking was working.
To find the critical change, we used git-bisect and identified the commit which introduced the problem. With that commit the static library of our OpenCV bindings project was updated, because it was missing the device-architectures - it only had the simulator archs, basically x86_64.
After that, we assumed, Wikitude might use OpenCV internally and we could get symbol collisions, even though the linker didn't complain about duplicate symbols. Though, Wikitude does not use OpenCV but a search for the combined use of Wikitude and OpenCV brought up some results without solutions:
So then we found out, Wikitude and OpenCV both include partly the same third party code.
The questions
In the linked posts, the Wikitude support answered quite openly, suggesting an internal discussion and coming back to the OPs. Though no further answers are in the thread, suggesting either there is none or the information has been exchanged through another channel.
In other posts, we saw the suggestion of using OpenCV with Wikitude, by preparing visual data and feed it to an input plugin. This suggests, that OpenCV and Wikitude can be used together.
- Can, and if, how can this be achieved in a Xamarin project like the one I described?
- Does it require a certain version of OpenCV? (We are currently using v3.3.1.)
Maybe the community also achieved this and I'm very looking forward to answers about that. We also contacted Wikitude support and will feedback information here, if we receive any, that is useful to answer the question.