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(¶meters);
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):
Any help would be appreciated.
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.
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.