Home > database >  detecting ArUco markers difference between openCV versions
detecting ArUco markers difference between openCV versions

Time:06-28

I have gotten someone else's code from at least a year ago, I don't have any information about which version of OpenCv they used, I am guessing maybe OpenCV 3. I am using OpenCV 4 and I need to "translate" their code to OpenCV 4.

Let's start with

from cv2 import aruco

They (old code I got) used the aruco.detectMarkers command similar to this:

corners, ids, rejectedImgPoints = aruco.detectMarkers(
    gray,
    aruco_dictionary,
    parameters,
    cameraMatrix,
    distCoeff
)

However, in the new Open CV 4, the inputs for "aruco.detectMarkers" are only these three: image (gray), aruco_dictionary and parameters so this command fails. I can get it to work by calling it as:

corners, ids, rejectedImgPoints = aruco.detectMarkers(
    gray,
    aruco_dictionary,
    parameters
    )

So camera matrix and distortion coefficients are not an input. However, if I am not giving the camera matrix and distortion coefficients as an input, am I not loosing some input information? Will that give me a different output than they have originally gotten using their command?

I can't find any documentation for the older version of the aruco.detectMarkers function to compare these two.

CodePudding user response:

You need to use two functions:

  • detectMarkers, gives you the quad and id for every marker it finds in the picture
  • estimatePoseSingleMarkers (or the same for boards...) will recover the poses of the passed in marker quads, given the camera matrix and distortion coefficients, and length (applies to all given markers).

Do not explicitly undistort the picture.

Opencv v4.6.0 got a bunch of changes to the aruco code. It also seems to have removed some misguided implementation options, so that is good. detectMarkers is not supposed to undistort the picture or the points. That's what estimatePose... is already doing.

The additional "Note" in the v4.6.0 docs is simply wrong. You might wanna open an issue about that.

  • Related