How to share the data between Emgu CV C# app and C++ library

Sunday, November 28, 2021

Emgu CV is a cross platform .Net wrapper to the OpenCV image processing library which allows OpenCV functions to be called from .NET compatible languages. The wrapper can be compiled by Visual Studio and Unity, it can run on Windows, Linux, Mac OS, iOS and Android.

It is a very nice and handy C# library. But the document is not adequate, especially when the code involves mixing language programming such as C# app calls C++ library. There is no clear document showing how to share data between Emgu CV and native C++ library.

Most people will marshal the data then transfer the data between C# and C++. But since Emgu CV is a thin wrap around the OpenCV C++ library, it is rational to believe that we can share the data between C# side and C++ side.

This example show how to share the data between Emgu CV C# app and C++ library: https://github.com/yangcha/emgucv-cpp . I will explain in more detail later on.