- Please visit the following link to download the source code of OpenCV 3.1:https://github.com/opencv/opencv/tree/3.1.0
- Please visit the following link to download the "opencv_contrib" repository:https://github.com/opencv/opencv_contrib/tree/3.1.0
- Please visit the following link for the instructions on how to install OpenCV on your machine:https://github.com/opencv/opencv_contrib/blob/master/README.md
- Note down where the libraries are built, and where the header files are copied.
- Install the Computer Vision Toolbox:
- Check if your license covers the Computer Vision Toolbox by typing the following command in the MATLAB Command Window:>> ver
- If it does, open the MATLAB Desktop application and click on the "Add-Ons" dropdown button in the Home toolstrip.
- Click on "Get Add-Ons". This will open the "Add-Ons" window.
- In the search bar, search for "Computer Vision Toolbox" and install it.
- Check if your license covers the Computer Vision Toolbox by typing the following command in the MATLAB Command Window:
- Install the OpenCV Interface support package following the instructions here:https://www.mathworks.com/help/vision/ug/opencv-interface.html#buxwnlt
- (Optional) Please visit the following link for a video explanation on using OpenCV with MATLAB:
https://www.mathworks.com/videos/using-opencv-with-matlab-97710.htmlArUcoUse the attached "getaruco.cpp" file as an example, and run the following command in the MATLAB Command Window:>> mexOpenCV getaruco.cpp -L~/opencv310/lib/ -lopencv_aruco.3.1.0 -I/usr/local/includeIt is important to replace the paths according to your OpenCV installation. Please consider the following explanation of the operations that the flags mentioned in the command above perform:- "-L": looks in the directory for library files
- "-l": links with a library file
- "-I": adds the include directory of header files
This should generate a MEX file called "getaruco.mex*" (* replaced by the OS identifier). Now you can use the "getaruco" function like any other MATLAB function.In the provided example, to create a 1000-by-1000 uint8 image, with a "markerId" of 12, and border bits size 1, use the following:>> im = getaruco(1000, 12, 1);You can then access any class from the ArUco module by changing the "mexFunction" in the "getaruco.cpp" file.For different ArUco functions, it is suggested to create different CPP files. For instance, "getArucoFunctionOne.cpp", "getArucoFunctionTwo.cpp", and so on.Moreover, please note that MATLAB does not link against the "highgui", "videoio", or "imgcodecs" libraries. Hence, functions such as "imshow" present within the "OpenCV" library should not be available.