Portable C Code Generation for Functions That Use OpenCV Library
You can generate portable C code for Computer Vision Toolbox™ functions that use the OpenCV library. The generated code calls OpenCV APIs and therefore requires compatible OpenCV header files and libraries during compilation and linking.
The flowchart illustrates the workflow for generating code that uses the OpenCV library.

For MATLAB® host platforms, the generated code uses the OpenCV libraries provided through
packNGo(MATLAB Coder). Your compiler must be compatible with the compiler used to build these libraries.The following compilers are used to build the OpenCV libraries for MATLAB host:
Operating System Compatible Compiler Windows® 64 bit Microsoft® Visual Studio® 2015 or later (Professional or Community editions) Linux® 64 bit gcc-4.9.3 (g++) Mac 64 bit Xcode 6.2.0 (Clang++) For non-host targets, you must provide OpenCV libraries that are compatible with the target platform and compiler. These libraries must match the target hardware architecture and toolchain for successful compilation and linking.
See Also
Install and Use Computer Vision Toolbox Interface for OpenCV in MATLAB