Ask Your Question
0

Valid marker ends up in rejected candidates with aruco marker detection

asked 2016-04-06 17:35:20 -0500

Martinator gravatar image

Hello, I am trying to test the basic functionalities with aruco. I have two problems. I am getting an numpad_chunk() : invalid pointer error when the program ends (which is bad, but bearable). The second problem is that I can not detect the marker from the tutorial and it is found in the rejected candidates output. I have used the same dictionary as in the tutorial. What is the problem? My code is in c++ as follows:

#include "opencv2/opencv.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/videoio/videoio.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/aruco.hpp"
#include <vector>

using namespace cv;
using namespace std;

int main (int argc, char** argv)
{
    VideoCapture cap;

    if(!cap.open(0)){
        return 0;
    }
    aruco::DetectorParameters parameters;
    aruco::Dictionary dictionary = aruco::getPredefinedDictionary(aruco::DICT_6X6_250);
    Ptr<aruco::Dictionary> dictionaryPtr(&dictionary) ;
    Ptr<aruco::DetectorParameters> parametersPtr(&parameters);
    for(;;){
        Mat inputImage;
        cap >> inputImage;
        vector< int > markerIds;
        vector< vector<Point2f> > markerCorners, rejectedCandidates;
        aruco::detectMarkers(inputImage, dictionaryPtr, markerCorners, markerIds, parametersPtr, rejectedCandidates);

        Mat outputImage = inputImage.clone(); 
        aruco::drawDetectedMarkers(outputImage, markerCorners, markerIds);
        cout << rejectedCandidates.size() << endl;
        for(std::vector< vector<Point2f> >::iterator it = rejectedCandidates.begin(); it != rejectedCandidates.end(); ++it) {
            vector<Point2f> sqPoints = *it;
            //cout << sqPoints.size() << endl;
            //Point pt2(it[1].x, it[1].y);
            line(outputImage, sqPoints[0], sqPoints[1], CV_RGB(255, 0 , 0));
            line(outputImage, sqPoints[2], sqPoints[1], CV_RGB(255, 0 , 0));
            line(outputImage, sqPoints[2], sqPoints[3], CV_RGB(255, 0 , 0));
            line(outputImage, sqPoints[0], sqPoints[3], CV_RGB(255, 0 , 0));
        }
        if(inputImage.empty()) break;
        imshow("Webcam", outputImage);
        if(waitKey(1) >= 0) break;
    }
    dictionaryPtr.release();
    parametersPtr.release();
    return 0;
}

Here is a screenshot of what I am getting as output (I draw all rejected candidates with a red outline):

image description

Any help would be appreciated.

edit retag flag offensive close merge delete

Comments

Just a small guess, but could you print the marker without the text just beneath it? I guess it might be screwing with the rejection process.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-04-07 04:43:32 -0500 )edit

Hello, I will try, but as far as I understand, once the corners are found, the marker image will be cut out using these corners from the original and then thresholded with Otsu threshold so the letters there should not interfere with the process.

I guess the culprid should be somewhere in the bit detection process.

Martinator gravatar imageMartinator ( 2016-04-08 08:19:46 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
2

answered 2016-04-17 09:21:17 -0500

Martinator gravatar image

Hello, the problem I had was, that the dictionary has changed and that the tutorial markers are no longer used. The tutorial marker with id 23 was different from the one generated from the new dictionary. The solution is to only use markers generated using the drawMarker function.

image description

It was a stupid mistake but it just goes to show that one should not rely on old tutorials. OpenCV cnd its modules change really fast.

edit flag offensive delete link more
0

answered 2018-12-01 03:20:13 -0500

afrixs gravatar image

Another possible reason is that some camera drivers (I used Xbox One Kinect camera running in ROS via openni2_launch package) mirror received image and only symmetric markers are detected. I was banging my head for about 5 hours until I found that the image was flipped, so hopefully this will help someone with the same problem.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-04-06 17:31:58 -0500

Seen: 903 times

Last updated: Apr 17 '16