How to find the id/index of aruco marker based on its relative position?
This is the image I want to capture with my camera(without the colourful box of course).
I want to find the index of aruco marker in the green box. Each of the green box is either at the top, right, bottom, left of the marker in the red box. The marker in the blue box should not be detected.
When I detect the marker, I only get a list of marker values. How do I pinpoint which marker is where?
How do I get the coordinate in 2d and 3d?
This is my current progress(simplified). As of now, Im able to draw the axis(have correct camera calibration parameters). My development is in Java and I use Aruco from OpenCv contrib.
try
{
Aruco.detectMarkers(image, markerDictionary, corners, ids, parameters, rejectedImgPoints);
}
catch (Exception ex)
{
Log.e(TAG, "detectMarkers Exception : " + ex.getMessage());
}
if (corners.size() > 0)
{
try
{
Aruco.drawDetectedMarkers(image, corners, ids);
}
catch (Exception ex)
{
Log.e(TAG, "drawDetectedMarkers Exception : " + ex.getMessage());
}
if (isCalibrationParametersAvailable)
{
try
{
Aruco.estimatePoseSingleMarkers(corners, markerLength, cameraMatrix, distCoeffs, rvecs, tvecs);
} catch (Exception ex)
{
Log.e(TAG, "estimatePoseSingleMarkers Exception : " + ex.getMessage());
}
try
{
for (int i = 0; i<ids.toArray().length; i++)
{
Aruco.drawAxis(image, cameraMatrix, distCoeffs, rvecs.row(i), tvecs.row(i), markerLength * 0.5f);
}
} catch (Exception ex)
{
Log.e(TAG, "drawAxis Exception : " + ex.getMessage());
}
}
// centerMarkerIndex is the ids index of marker in the red box
// targetMarkerValue is the marker value in the green box
// ids contains the list of detected markers
int idTopIndex = GetIndexOfTop(centerMarkerIndex, targetMarkerValue, ids)
}
Thanks.
hmm, your colors are wrong for the blue ones ?
and where is your code ?
Forgot to mention the blue color. Edited.
no, i mean, you only have a single marker id for all of the outline squares. so what does "blue" or "green" mean here ?
how, exactly ? again, please show your code !
Added source code.
What I want is to get the index of certain marker in specific position. In the example, I have multiple marker with the same id. I have 10 markers with marker id = 9. Which of this 10 markers is at the top of marker with id 8(red box)? Make sense?