Search code examples
opencvcomputer-visionaugmented-realityaruco

Aruco MarkerDetector undistorts image?


I am currently using the aruco library to track fiducial markers, and I use the detect() method of the MarkerDetector class. The detect() method takes as input the camera parameters (camera matrix, distortion coefs), the length of the marker and the image. I actually use the function cv::undistort() to undistort the image before giving it as input to detect(). But i was asking myself if the detect() method already undistorts the image ? Which means that i should give the raw image as input to detect(), instead of the undistorted one. I read the doc of the function, but no information is given about that.

Thank you for your answers :-)


Solution

  • edit: I don't know the standalone library and can only talk about the aruco module of OpenCV

    If you pass an undistorted picture to the aruco API, do not pass any distortion coefficients to the aruco API. You should however pass the "raw" image instead (and distortion coefficients in the following call), because that spares you from having to undistort the entire picture, which costs more than doing it to a few points.

    The aruco module API was recently changed to clarify this... if I remember correctly. The detectMarkers() method is not supposed to do the undistorting, and does not do that. The undistorting, of points, is supposed to happen in the pose estimation call, estimatePoseSingleMarkers() or related ones, which comes after.

    Yes, some parts of the docs are bad, and I wouldn't put all my trust in the implementation either.