I am looking for a way to use OpenCV in a Unity project and my target platform is an Android device.
I know that some assets exists on Unity asset store but I DO
Just to share what i had to do to compile the .so using C++17 with OpenCV 4.1.0 in Visual Studio.
First, i had to update my AndroidNDK via the VS-Installer to n15c. Using a separately downloaded NDK did not work for me. When starting to build, the NDK_ROOT will be printed so you can check if it's setup correctly.
Follow Pierre's Steps 1 and 2. In Linker->Input, i only set the library name in "Library Dependencies". I my case, that's opencv_java4, which is how the Linker likes it, derived from libopencv_java4.so
In Tab General set:
In Tab Language set:
In Tab Code Generation set Enable C++ Exceptions to yes
In Tab Linker->Command Line add -lm -lz
I also had to set Not using Precompiled Headers in C/C++ -> Precompiled Headers. I don't think this is generally necessary though.
Hope this will be helpful for someone!