Skip to content

Commit

Permalink
fixed issue with wrong marker vertex order, hence smoothing works cor…
Browse files Browse the repository at this point in the history
…rectly now
  • Loading branch information
internaut committed Jul 7, 2014
1 parent feb11ce commit ed151a9
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 192 deletions.
45 changes: 22 additions & 23 deletions detect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,28 @@ void Detect::processFrame() {
findContours();
findMarkerCandidates();
identifyMarkers();
estimatePositions();
}

void Detect::estimateMarkersPoses() {
// estimate the 3D pose of each found marker
for (vector<Marker *>::iterator it = foundMarkers.begin();
it != foundMarkers.end();
++it)
{
Marker *marker = *it;

// find marker pose from 3D-2D point correspondences between <normMarkerCoord3D>
// and 2D points in <marker->getPoints()>
cv::Mat rVec; // pose rotation vector
cv::Mat tVec; // pose translation vector
cv::solvePnP(normMarkerCoord3D, marker->getPoints(),
camMat, distCoeff,
rVec, tVec,
false);

// generate an OpenGL model-view matrix from the rotation and translation vectors
marker->updatePoseMat(rVec, tVec);
}
}

cv::Mat *Detect::getOutputFrame() const {
Expand Down Expand Up @@ -440,28 +461,6 @@ void Detect::identifyMarkers() {
}
}

void Detect::estimatePositions() {
// estimate the 3D pose of each found marker
for (vector<Marker *>::iterator it = foundMarkers.begin();
it != foundMarkers.end();
++it)
{
Marker *marker = *it;

// find marker pose from 3D-2D point correspondences between <normMarkerCoord3D>
// and 2D points in <marker->getPoints()>
cv::Mat rVec; // pose rotation vector
cv::Mat tVec; // pose translation vector
cv::solvePnP(normMarkerCoord3D, marker->getPoints(),
camMat, distCoeff,
rVec, tVec,
false);

// generate an OpenGL model-view matrix from the rotation and translation vectors
marker->updatePoseMat(rVec, tVec);
}
}

void Detect::discardDuplicateMarkers(vector<Marker> &markerList) {
const float maxDuplDistSquared = OCV_AR_CONF_MAX_DUPLICATE_DIST * OCV_AR_CONF_MAX_DUPLICATE_DIST;

Expand Down
10 changes: 5 additions & 5 deletions detect.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ class Detect {
*/
void processFrame();

/**
* After detection and identification of the markers, estimate their 3D pose.
*/
void estimateMarkersPoses();

/**
* Get the output frame according to the "frame output level" set via
* <setFrameOutputLevel()>. If this level is set to PROC_LEVEL_DEFAULT, it will
Expand Down Expand Up @@ -167,11 +172,6 @@ class Detect {
*/
void identifyMarkers();

/**
* Detection step 5 - estimating the 3D pose of each found valid marker.
*/
void estimatePositions();

/**
* Discard duplicate markers after detection step 4.
*/
Expand Down
Loading

0 comments on commit ed151a9

Please sign in to comment.