A base project to use computer vision algorithms provided by OpenCV inside the Unity game engine. The plugin was built on MacOS and therefore this project works on either MacOS or as an IOS build. The code for the plugin can be found here. Please refer to the code for details on the implementation.
Save image as black and white
Saves an image as black and white
Preprocessing, detecting edges
First we detect the edges of the image.
Preprocessing, detecting outer hull
Next, we detect the outer hull and set it as ROI.
Rotation, scaling and overlay on a new image, at an offset
Finally, rotates, scales and translates an image overlaying it on a new image.
For more details on the implementation, please see the code(https://github.com/sonnyky/UnityCvPlugin).
Compare image similarity with shape matching
There is no sample image to show, this function will return the similarity value. The lower the better.
Compare image similarity with feature matching (SIFT)
The reference and comparison images
Fun fact, OpenCV and Unity has a different axes system, and also RGB order (it’s BRG in OpenCV). This is why the input and comparison images are upside down, and the color is wrong. However, the SIFT algorithm is not affected by this and outputs correctly. Only the final matched image was converted to show the correct coloring and orientation.
Check out the plugin code. And make sure to have the bundle in the correct OSX path in Unity. Refer to the project for details.