sonnyky / UnityCv

A base project to work with native OpenCV plugins

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UnityCv

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.

What's inside

Save image as black and white

Saves an image as black and white

Image transformation

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.

Usage

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.

About

A base project to work with native OpenCV plugins

License:MIT License


Languages

Language:C# 100.0%