ArUco Marker Detection with OpenCV

ArUco Marker Detection

Class Aruco- Java

Pose estimation is of great importance in many computer vision applications: robot navigation, augmented reality, and many more. This process is based on finding correspondences between points in the real environment and their 2d image projection. This is usually a difficult step, and thus it is common to use synthetic or fiducial markers to make it easier.

One of the most popular approaches is the use of binary square fiducial markers. The main benefit of these markers is that a single marker provides enough correspondences (its four corners) to obtain the camera pose. Also, the inner binary codification makes them specially robust, allowing the possibility of applying error detection and correction techniques.

  • cv::aruco::detectMarkers (InputArray image, const Ptr< Dictionary > &dictionary, OutputArrayOfArrays corners, OutputArray ids, const Ptr< DetectorParameters > &parameters=DetectorParameters::create(), OutputArrayOfArrays rejectedImgPoints=noArray())
    • Basic marker detection
  • cv::aruco::drawDetectedMarkers(InputOutputArray image, InputArrayOfArrays corners, InputArray ids=noArray(), Scalar borderColor=Scalar(0, 255, 0))
    • Draw detected markers in image
  • cv::aruco::estimatePoseSingleMarkers(InputArrayOfArrays corners, float markerLength, InputArray cameraMatrix, InputArray distCoeffs, OutputArray rvecs, OutputArray tvecs, OutputArray _objPoints=noArray(), Ptr< EstimateParameters > estimateParameters=EstimateParameters::create())
    • Pose estimation for single markers

Java

Class Aruco- Java

  • detectMarkers​(Mat image, Dictionary dictionary, java.util.List corners, Mat ids)

  • drawDetectedMarkers​(Mat image, java.util.List corners, Mat ids, Scalar borderColor)

  • estimatePoseSingleMarkers​(java.util.List corners, float markerLength, Mat cameraMatrix, Mat distCoeffs, Mat rvecs, Mat tvecs)

Pose Estimation

Calibration

Camera Calibration

To perform camera pose estimation, you need to know your camera’s calibration parameters. These are the camera matrix and distortion coefficients.

As a result of the calibration, you get a camera matrix: a matrix of 3x3 elements with the focal distances and the camera center coordinates (a.k.a intrinsic parameters), and the distortion coefficients: a vector of 5 or more elements that models the distortion produced by your camera.