vinjn / articles

Everything is possible
8 stars 0 forks source link

notes_of_ARToolKitPlus #1

Open vinjn opened 11 years ago

vinjn commented 11 years ago

Latest version 2.3.0

/samples/simple/main.cpp

// create a tracker that does
ARToolKitPlus::TrackerSingleMarker tracker(width, height, 
8,  //  -can detect a maximum of 8 patterns in one images
6, 6,  //  describes the pattern image width (must be 6 for binary markers)
6,  // describes the maximum resolution at which a pattern is sampled from the camera image
0 //  describes the maximum number of pattern files that can be loaded
);

Two types of calibration files .xml loadOpenCVCalib .cal loadARTKCalib

/// Returns an opengl-style modelview transformation matrix
virtual const ARFloat* getModelViewMatrix() const {
    return gl_para;
}

/// Returns an opengl-style projection transformation matrix
virtual const ARFloat* getProjectionMatrix() const {
    return gl_cpara;
}
vinjn commented 11 years ago
// do the OpenGL camera setup
// glMatrixMode(GL_PROJECTION)
// glLoadMatrixf(tracker.getProjectionMatrix());

// here we go, just two calls to find the camera pose
std::vector<int> markerId = tracker.calc(cameraBuffer);
tracker.selectBestMarkerByCf();
float conf = tracker.getConfidence();

// use the result of calc() to setup the OpenGL transformation
// glMatrixMode(GL_MODELVIEW)
// glLoadMatrixf(tracker.getModelViewMatrix());

printf("\n\nFound marker %d  (confidence %d%%)\n\nPose-Matrix:\n  ", markerId[0], (int(conf * 100.0f)));
for (int i = 0; i < 16; i++)
    printf("%.2f  %s", tracker.getModelViewMatrix()[i], (i % 4 == 3) ? "\n  " : "");