Hi,
I followed the basic tutorial for detecting and placing an aruco marker but during my simulation my axis and so my origin is not centered on my marker.
Here is how axis are placed and where the origin is (top image) and what i would like to have at the end (down image (from internet)) :
Here is my code :
vector<cv::Vec3d>rvecs; //rotation vector from detectMarkers
cv::Ptr<cv::aruco::DetectorParameters> parameters = cv::aruco::DetectorParameters::create();
cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
cv::aruco::detectMarkers(frame, dictionary, corners, ids, parameters);
float mtx[3][3] = {
{229.41206666, 0.00000000e+00, 292.21276158 } ,
{0.00000000e+00, 229.41206666, 163.36008624} ,
{0.00000000e+00, 0.00000000e+00, 1.00000000e+00}
};
float dist[14][1] = {
{0.15749949} ,
{0.71279781} ,
{ -0.00673416} ,
{-0.04085565} ,
{3.81203065} ,
{0.12853096} ,
{0.76355458} ,
{ 3.70903916} ,
{0.} ,
{0.} ,
{0.} ,
{0.}
};
cv::Mat cameraMatrix = cv::Mat(3, 3, CV_32F, mtx);
cv::Mat distCoeffs = cv::Mat(14, 1, CV_32F, dist);
if(ids.size()>0)
{
cv::aruco::estimatePoseSingleMarkers(corners,1,cameraMatrix,distCoeffs,rvecs,translation_vectors);
cv::aruco::drawDetectedMarkers(frame, corners, ids);
cv::drawFrameAxes(frame,cameraMatrix,distCoeffs,rvecs,translation_vectors,1);
}
Corner, translation_vector, ids etc are in parameters of my function.
I think the problem is when I call “estimatePoseSingleMarkers”. It sets the origin of the marker to the first corner stored in my corner vector.
As a result, my translation vectors are based on this corner and not on the center of the marker, which is bad and I don’t know and understand how to solve it.
Any idea ?
Thanks !