In one of my recent projects, I needed to use OpenCV from within Unity, in IOS. The asset called OpenCVForUnity is overkill because I didn't need the whole OpenCV library, just a few functions. In addition, this asset does not implement the whole OpenCV library so unless you know that what you need is included you may find it lacking when you discover it does not support some functions you need. As my project involves some trial and error and mixing algorithms together I decided to go with a native plugin.
Overview
In IOS, a native library is built as a bundle. We need to put this bundle inside Unity's Plugins/OSX folder to use it. Therefore, we need to create two projects.
- An XCode project to build the native plugin.
- A Unity project to use the plugin.
Dependencies
Of course, since we need to use OpenCV we will have to install it first. Tutorials on installing OpenCV on IOS are abundant and I will not include them here. Assuming you have installed OpenCV go to the next step.
The Bundle from XCode
First we create a new XCode project.
Select File -> New Project and choose Bundle template.
After setting up the project settings, OpenCV install paths and other parameters, create a new file for the image processing methods. The XCode project that I created can be found here. Inside are some computer vision algorithms that I needed on some of my projects.
After setting up the project settings, OpenCV install paths and other parameters, create a new file for the image processing methods. The XCode project that I created can be found here. Inside are some computer vision algorithms that I needed on some of my projects.
The Unity part
Since I needed to use the OpenCV methods in Unity, I implemented it as a native plugin callable from Unity. The Unity project can be found here.
You can clone both repositories and play with the parameters and methods to suit your project. Please let me know in the comments or in the github page if you have any problems.
This comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDelete