Ask Your Question
0

How to find the id/index of aruco marker based on its relative position?

asked 2018-12-13 03:55:07 -0600

syaifulnizamyahya gravatar image

updated 2018-12-13 05:09:31 -0600

This is the image I want to capture with my camera(without the colourful box of course).

image description

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.

edit retag flag offensive close merge delete

Comments

hmm, your colors are wrong for the blue ones ?

and where is your code ?

berak gravatar imageberak ( 2018-12-13 03:59:29 -0600 )edit

Forgot to mention the blue color. Edited.

syaifulnizamyahya gravatar imagesyaifulnizamyahya ( 2018-12-13 04:52:07 -0600 )edit

no, i mean, you only have a single marker id for all of the outline squares. so what does "blue" or "green" mean here ?

When I detect the marker

how, exactly ? again, please show your code !

berak gravatar imageberak ( 2018-12-13 04:58:45 -0600 )edit
1

Added source code.

syaifulnizamyahya gravatar imagesyaifulnizamyahya ( 2018-12-13 05:08:16 -0600 )edit
1

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?

syaifulnizamyahya gravatar imagesyaifulnizamyahya ( 2018-12-13 05:14:02 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2018-12-13 05:07:15 -0600

berak gravatar image

updated 2018-12-13 05:09:38 -0600

for the 2d points, you have:

 Aruco.detectMarkers(image, markerDictionary, corners, ids, parameters, rejectedImgPoints);

the corners are a List<Mat> , and each Mat contains the 4 corner points of a marker, in clockwise order.

it's nicely explained in the c++ docs

the 3d positions (relative to the camera) are in the tvecs , obtained from Aruco.estimatePoseSingleMarkers

edit flag offensive delete link more

Comments

1

Unable to upvote

syaifulnizamyahya gravatar imagesyaifulnizamyahya ( 2018-12-13 05:19:30 -0600 )edit

don't worry, i don't need any more karma ;)

berak gravatar imageberak ( 2018-12-13 05:21:51 -0600 )edit
1

Since sometime the image might be rotated, I also need to know about the rotation right? Which I can get from rvecs. Right?

syaifulnizamyahya gravatar imagesyaifulnizamyahya ( 2018-12-14 06:00:05 -0600 )edit

all correct ;)

berak gravatar imageberak ( 2018-12-14 06:19:37 -0600 )edit
-1

answered 2019-09-24 05:25:22 -0600

Which version of OpenCV are you using?

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-12-13 03:55:07 -0600

Seen: 2,469 times

Last updated: Sep 24 '19