フィルターのクリア

How to detect ArUco markers in MATLAB?

40 ビュー (過去 30 日間)
MathWorks Support Team
MathWorks Support Team 2017 年 11 月 24 日
編集済み: MathWorks Support Team 2024 年 9 月 23 日 17:29
I want to read ArUco markers using MATLAB for my workflow.
Does MATLAB support reading ArUco markers?

採用された回答

MathWorks Support Team
MathWorks Support Team 2024 年 4 月 22 日
編集済み: MathWorks Support Team 2024 年 9 月 23 日 17:29
Since MATLAB R2024a:
To detect ArUco markers in an image, you can use the "readArucoMarker" function in MATLAB. This function is present within the Computer Vision Toolbox. It enables you to restrict detections to specific marker families and to specify the marker size to detect. It also provides several name-value arguments to adjust adaptive thresholding, contour filtering, bit extraction, and subpixel corner refinement.
Please visit the following link for more information on the "readArucoMarker" function:https://www.mathworks.com/help/vision/ref/readarucomarker.html
Additionally, if you would like to generate ArUco marker images, please consider using the "generateArucoMarker" function.
Please visit the following page for more information on the "generateArucoMarker" function:https://www.mathworks.com/help/vision/ref/generatearucomarker.html
For releases prior to MATLAB R2024a:
There is no toolbox that can read ArUco markers in MATLAB directly. However, it is possible to get this functionality through the OpenCV interface support package:https://www.mathworks.com/discovery/matlab-opencv.html
Generally, the Computer Vision System Toolbox OpenCV Interface allows you to bring existing OpenCV files and projects into MATLAB using the MEX Interface. For OpenCV 3 and above, the ArUco modules are part of the "opencv_contrib" repository:
https://github.com/opencv/opencv_contrib/tree/master/modules/aruco.
Any module located in the "opencv_contrib" repository is not part of the core OpenCV library and is therefore not built, linked, or shipped with the OpenCV interface. However, it is possible to build OpenCV with the "opencv_contrib" modules outside of MATLAB and its installation, and link against it while creating a MEX file. This procedure gives access to the functions of the "opencv_contrib" module of interest. The general steps are as follows: OpenCV
MATLAB Computer Vision Toolbox
  • 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.
  • Install the OpenCV Interface support package following the instructions here:
  • (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.html
ArUcoUse 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/include
It 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.

その他の回答 (0 件)

製品


リリース

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by