Ask Your Question

How can I draw the x,y, and z axis of a aruco marker and know the distance and the rotation relative to the camera?

asked 2019-01-06 14:54:07 -0500

czjczjczj1 gravatar image

updated 2019-01-06 14:54:56 -0500

Hello, I ran the marker_detection.exe and the aruco markers were successfully detected by passing arguments " marker_detection.exe --ci=1 -d=10". But what kind of arguments should I pass to draw the x,y, and z axis? How can I know the distance and the rotation of a marker relative to the camera? Thanks for any help.

Basic marker detection
Usage: test.exe [params]

            Camera intrinsic parameters. Needed for camera pose
    --ci (value:0)
            Camera id if input doesnt come from video (-v)
            dictionary: DICT_4X4_50=0, DICT_4X4_100=1, DICT_4X4_250=2,DICT_4X4_1000=3, DICT_5X5_50=4, DICT_5X5_100=5, DICT_5X5_250=6, DICT_5X5_1000=7, DICT_6X6_50=8, DICT_6X6_100=9, DICT_6X6_250=10, DICT_6X6_1000=11, DICT_7X7_50=12,DICT_7X7_100=13, DICT_7X7_250=14, DICT_7X7_1000=15, DICT_ARUCO_ORIGINAL = 16,DICT_APRILTAG_16h5=17, DICT_APRILTAG_25h9=18, DICT_APRILTAG_36h10=19, DICT_APRILTAG_36h11=20
            File of marker detector parameters
    -l (value:0.1)
            Marker side lenght (in meters). Needed for correct scale in camera pose
            show rejected candidates too
            Input from video file, if ommited, input comes from camera
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2019-01-07 01:15:52 -0500

berak gravatar image

updated 2019-01-07 01:43:33 -0500

have a look at the sample code, again.

aruco::detectMarkers() will give you a vector< vector< Point2f > > corners , that's the position in the image (4 corner points for each marker).

aruco::estimatePoseSingleMarkers() will give you an rvec (that's the rotation in euler angles) and a tvec (the translation wrt. the camera) for each detected marker.

however, to estimate the pose, you have to calibrate your camera first, and pass the filename with the camera params to you program like:

detect_markers -c=cam.yml
edit flag offensive delete link more



@berak Thanks for your reply. I have already calibrated my camera. But I still got some questions:

  1. What should I pass for the "--dp" and the "-r " ?

  2. How can I print out the x, y, and z and the rotation for a marker? What I could see from the prompt is only something like" Detection Time = 26.4501 ms (Mean = 28.9039 ms) ". It is possible to store the information in a file? (Sorry, I am very new to C++, I have tried my best to understand the code, but I don't have much time left for my project.)

  3. Is there any python samples for the aruco detection? I could not find them online.

czjczjczj1 gravatar imageczjczjczj1 ( 2019-01-07 06:31:49 -0500 )edit
  1. --dp=detector_params.yml it's this file here (you can also edit it) -r , that is "show rejected" (and it has no value)

  2. you can just do cout << rvec[i] << endl; (same for other Mat's)

  3. sorry, no python samples ;(

berak gravatar imageberak ( 2019-01-07 06:46:34 -0500 )edit

Yes, there is sample found online and also on youtube too. I can't recalled dating back to 2014. I was using raspberry pi. The arcu is awesome.

supra56 gravatar imagesupra56 ( 2019-01-07 07:34:18 -0500 )edit

Thank you very much for your relpy. This was what I added to the sample code: cout << rvecs[i] << tvecs[i] << endl; and then I got something like: [2.92855, -0.357194, -0.195773][-0.021049, -0.0170902, 0.102746]

  1. I am not sure what does the first five numbers represent. Could you explain it a little bit for me, please? It seems that the last one is the distance between the aruco marker and the camera lens in z axis (blue axis), right? So the third parameter is for the rotation of blue axis? I don't know when it would be negative and when it would be positive.
  2. What is the detector_params.yml used for and how do I use it?
  3. Which axis is x,y,z axis? Actually I just want to know which parameter is for green axis and which one is for ...
czjczjczj1 gravatar imageczjczjczj1 ( 2019-01-19 17:14:45 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2019-01-06 14:54:07 -0500

Seen: 30 times

Last updated: Jan 07