What is the meaning of: TheMarkers[0].Tvec.at<Vec3f>(0,0)[0];
Hey!
I would like to ask a question. I am using Aruco AR library, and I would like to define the coordinates of a marker. A part of my c++ code:
double x_t = -TheMarkers[0].Tvec.at<Vec3f>(0,0)[0];
double y_t = TheMarkers[0].Tvec.at<Vec3f>(0,0)[1];
double z_t = TheMarkers[0].Tvec.at<Vec3f>(0,0)[2];
To be honest I do not know what is the exact meaning of these lines. What I have so far figured out using stackoverflow and this site: (Let's see only the first line):
double x_t = -TheMarkers[0].Tvec.at<Vec3f>(0,0)[0];
TheMarkers[0]: the "0" index means that we want to inquire/get the first marker detected. It is clear.
Tvec: This is the 3D translation vector with x,y,z translation values. So how far is my marker relating to my camera coordinate system.
The next would be my first question: What does "at" mean at "Tvec.at"? I found an information on the internet about what does Vec3f mean: The Vec3f class provides a vector object for 3 dimensional locations or RGB pixel values.
After that the (0,0) part is also vague to me. Why should I use (0,0)?
The index at the end ([0]) is clear for me...
Thanks in advance for the answer!
well I understand it party, but still have question, so I am not totally familiar with the example line. As far as I know Aruco is totally based on OpenCV...Sorry if I made mistake for putting this question here, but I am of the opinion of that it is the right site to place this question.
no fear. at least tell us the type of Markers.TVec. if it is Vec3f (or Vec3d), it should boil down to a simple:
TheMarkers[0][0], TheMarkers[0][1], TheMarkers[0][2]
, etc.the type of "TVec" is: cv::Mat
sad as it is, you'll have to query Markers[i].TVec.type(),
and use the appropriate
at<type>(row,col)[channel]
syntax then.Really thanks for your help! TheMarkers[0].Tvec.type() = 5. To be honest I am suprised a bit, because of this "five" type...
5==CV_32F==float
stupid as it is, - you got a 1 element Mat(thus (0,0) index) with 3 float channels( thus the final [i] indexing) there.(above is wrong, please see answer below)
(Vec3f is actually a Mat, too, but it has the additional [] shortcut)
ohh i see! Thank you very much! I think now I got the meaning of the line :)