Skip to content

Commit

Permalink
improves to viewMatrix_GL and related code
Browse files Browse the repository at this point in the history
  • Loading branch information
kalwalt committed Feb 6, 2025
1 parent eee44b8 commit cf180fb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion WebARKit/WebARKitPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

WebARKitPatternTrackingInfo::WebARKitPatternTrackingInfo() {
pose3d = cv::Mat::zeros(4, 4, CV_64FC1);
glViewMatrix = cv::Mat::zeros(4, 4, CV_64F);
glViewMatrix = cv::Mat::zeros(4, 4, CV_64FC1);
m_scale = 1.0f;
}

Expand Down Expand Up @@ -67,6 +67,8 @@ void WebARKitPatternTrackingInfo::updateTrackable() {

void WebARKitPatternTrackingInfo::computeGLviewMatrix() { cv::transpose(pose3d, glViewMatrix); }

void WebARKitPatternTrackingInfo::computeGLviewMatrix(cv::Mat &pose) { cv::transpose(pose, glViewMatrix); }

void WebARKitPatternTrackingInfo::invertPose() {

/*cv::Mat invertPose(3, 4, CV_64FC1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ class WebARKitTracker::WebARKitTrackerImpl {

webarkit::cameraProjectionMatrix(camData, 0.1, 1000.0, frameWidth, frameHeight, m_cameraProjectionMatrix);

for (auto i = 0; i < 16; i++) {

WEBARKIT_LOGi("Camera Proj Matrix: %.2f\n", m_cameraProjectionMatrix[i]);

}

//1.9102363924347978, 0, 0, 0, 0, 2.5377457054523322, 0, 0, -0.013943280545895442, -0.005830389685211879, -1.0000002000000199, -1, 0, 0, -0.00020000002000000202, 0

_pyramid.clear();
_prevPyramid.clear();
_currentlyTrackedMarkers = 0;
Expand Down Expand Up @@ -383,6 +391,7 @@ class WebARKitTracker::WebARKitTrackerImpl {
// _patternTrackingInfo.computePose(_pattern.points3d, warpedCorners, m_camMatrix, m_distortionCoeff);
_patternTrackingInfo.getTrackablePose(_pose);
_patternTrackingInfo.updateTrackable();
_patternTrackingInfo.computeGLviewMatrix(_pose);
fill_output(m_H);
WEBARKIT_LOGi("Marker tracked ! Num. matches : %d\n", numMatches);
}
Expand Down Expand Up @@ -722,7 +731,6 @@ class WebARKitTracker::WebARKitTrackerImpl {
cv::Mat m_distortionCoeff;

std::array<double, 16> m_cameraProjectionMatrix;

private:
int _maxNumberOfMarkersToTrack;

Expand Down
2 changes: 2 additions & 0 deletions WebARKit/include/WebARKitPattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class WebARKitPatternTrackingInfo {

void computeGLviewMatrix();

void computeGLviewMatrix(cv::Mat &pose);

private:
float m_scale;
void invertPose();
Expand Down

0 comments on commit cf180fb

Please sign in to comment.