How to detect normal markers with ArUco module in OpenCV3.0

asked 2016-02-01 07:29:44 -0600

MarKS9 gravatar image

I want to detect a normal marker (Not an ArUco marker) using ArUco module in OpenCV3.0 . Below is the image for a normal marker.

image description

I have implemented the ArUco detection but not able to figure out how to make ArUco module to detect custom markers.

aruco::DetectorParameters detectorParams;
if (parser.has("dp")) {
bool readOk = readDetectorParameters(parser.get<string>("dp"), detectorParams);
if (!readOk) {
    cerr << "Invalid detector parameters file" << endl;
    return 0;
}
}

aruco::Dictionary dictionary =
aruco::getPredefinedDictionary(aruco::PREDEFINED_DICTIONARY_NAME(dictionaryId));

Mat camMatrix, distCoeffs;
if (estimatePose) {
bool readOk = readCameraParameters(parser.get<string>("c"), camMatrix, distCoeffs);
if (!readOk) {
    cerr << "Invalid camera file" << endl;
    return 0;
}
}

// detect markers and estimate pose
aruco::detectMarkers(image, dictionary, corners, ids, detectorParams, rejected);
if (estimatePose && ids.size() > 0)
    aruco::estimatePoseSingleMarkers(corners, markerLength, camMatrix, distCoeffs, rvecs,
        tvecs);

// draw results
image.copyTo(imageCopy);
if (ids.size() > 0) {
    aruco::drawDetectedMarkers(imageCopy, corners, ids);

    if (estimatePose) {
        for (unsigned int i = 0; i < ids.size(); i++)
            aruco::drawAxis(imageCopy, camMatrix, distCoeffs, rvecs[i], tvecs[i],
                markerLength * 0.5f);
    }
}

if (showRejected && rejected.size() > 0)
    aruco::drawDetectedMarkers(imageCopy, rejected, noArray(), Scalar(100, 0, 255));

imshow("out", imageCopy);
char key = (char)waitKey(waitTime);
if (key == 27) break;
}
edit retag flag offensive close merge delete

Comments

I am not sure that is even possible, since as far as I know, the module was built around the already existing markers ...

StevenPuttemans gravatar imageStevenPuttemans ( 2016-02-02 06:44:11 -0600 )edit