OpenCV Aruco Markers are not recognized on industrial cameras

1.2k views Asked by At

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;
}

Sample image from camera:

The problem is that markers are detected but for unknown reason they are rejected:

Rejected markers

I use OpenCV 3.1.

2

There are 2 answers

0
Piotr Siekański On BEST ANSWER

The problem is solved. I have to flip the image and now markers are detected flawlessly.

2
Joker On

Yes, flip the image in the x-direction will solve it.

opencv cv::flip(image, flippedImage, 1)