I'm working on detection of ARUCO markers on an industrial Automation Technology C2 cameras that are designed to detect laser fringe in triangulation scanner but they can also capture images. My problem is that the same markers are detected regardless the camera I use except the one I mentioned earlier. Minimal working example of my code is below:
#include <opencv2/highgui.hpp>
#include <opencv2/aruco/charuco.hpp>
using namespace std;
using namespace cv;
int main(int argc, char *argv[]) {
int squaresX = 10;
int squaresY = 7;
float squareLength = 28;
float markerLength = 19;
int dictionaryId = 6;
bool showRejected = true;
bool refindStrategy = true;
Ptr<aruco::DetectorParameters> detectorParams = aruco::DetectorParameters::create();
Ptr<aruco::Dictionary> dictionary =
aruco::getPredefinedDictionary(aruco::PREDEFINED_DICTIONARY_NAME(dictionaryId));
// create charuco board object
Ptr<aruco::CharucoBoard> charucoboard =
aruco::CharucoBoard::create(squaresX, squaresY, squareLength, markerLength, dictionary);
Ptr<aruco::Board> board = charucoboard.staticCast<aruco::Board>();
Mat image = imread("C:\\Users\\Piotrek\\Desktop\\calib\\022.jpg"), imageCopy;
vector< int > markerIds, charucoIds;
vector< vector< Point2f > > markerCorners, rejectedMarkers;
vector< Point2f > charucoCorners;
// detect markers
aruco::detectMarkers(image, dictionary, markerCorners, markerIds, detectorParams,
rejectedMarkers);
image.copyTo(imageCopy);
if (markerIds.size() > 0) {
aruco::drawDetectedMarkers(imageCopy, markerCorners);
}
if (showRejected && rejectedMarkers.size() > 0)
aruco::drawDetectedMarkers(imageCopy, rejectedMarkers, noArray(), Scalar(100, 0, 255));
//display results
imshow("out", imageCopy);
waitKey(0);
return 0;
}
The problem is that markers are detected but for unknown reason they are rejected:
I use OpenCV 3.1.
The problem is solved. I have to flip the image and now markers are detected flawlessly.