

Try imshow("frame", frame) for example. Void processImage(Color32* raw, int width, int height) If you use some cross platform tool like Qt Creator you will have something like CVTESTSHARED_EXPORT instead of “_declspec(dllexport)” which will automatically adapt to Linux, macOS, iOS and so on.Īnd in source file we’ll have this which is the actual function and image processing part of the project: extern "C" _declspec(dllexport) void processImage(Color32* raw, int width, int height)


struct Color32Īnd here’s how we need to define our exported function in the library. But before that we need to define a struct that we’ll use to receive images and video frames from Unity C# code. Then export those functions from the library and call them from C#. a and so on) in C++ which uses OpenCV the normal way.
OPENCV FOR MAC 2017 TUTORIAL HOW TO
Think about it like this, if you already know how to use OpenCV then you can create a very simple library file (.dll. Hopefully if you follow all the steps correctly you’ll have it running on your PC and Mobile.įirst and foremost, as you might already know, OpenCV or at least standard OpenCV uses C++ and not C# so we’ll need to somehow call OpenCV C++ functions from C#. Here’s an screenshot of the project shared in this post. In this example project I’ll use C# since that’s the language I’m familiar with but it shouldn’t be hard to adapt this to JavaScript (but you’re gonna do it yourself if needed, sorry) so let’s start. Unity allows some modified form of JavaScript and also C# for its scripting. For those of you who aren’t familiar with the subject, Unity is a very popular game engine which allows building games, apps and so called experiences with much ease. Of course we’ll be using official OpenCV libraries and not any assets or existing plugins. I’m going to describe how you can use OpenCV in Unity. This is a post that many people have requested recently.
