Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Valid marker ends up in rejected candidates with aruco marker detection

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.