Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improves to viewMatrix_GL and related code #32

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WebARKit/WebARKitManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ cv::Mat WebARKitManager::getGLViewMatrix() {

std::array<double, 16> WebARKitManager::getTransformationMatrix() {
std::array<double, 16> transformationMatrix;
webarkit::arglCameraViewRHf(m_tracker->getPoseMatrix(), transformationMatrix, 1.0f);
webarkit::arglCameraViewRHf((float (*)[4])m_tracker->getPoseMatrix2(), (float*)transformationMatrix.data(), 1.0f);
return transformationMatrix;
}

Expand Down
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 @@ -175,6 +183,9 @@ class WebARKitTracker::WebARKitTrackerImpl {

float* getPoseMatrix2() { return (float*)_patternTrackingInfo.trans; }

//float[3][4] getPoseMatrix3() { return _patternTrackingInfo.trans; }
//float (*getPoseMatrix3())[3][4] { return &_patternTrackingInfo.trans; }

cv::Mat getGLViewMatrix() { return _patternTrackingInfo.glViewMatrix; };

std::array<double, 16> getCameraProjectionMatrix() { return m_cameraProjectionMatrix; };
Expand Down Expand Up @@ -383,6 +394,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 +734,6 @@ class WebARKitTracker::WebARKitTrackerImpl {
cv::Mat m_distortionCoeff;

std::array<double, 16> m_cameraProjectionMatrix;

private:
int _maxNumberOfMarkersToTrack;

Expand Down Expand Up @@ -805,6 +816,9 @@ cv::Mat WebARKitTracker::getPoseMatrix() { return _trackerImpl->getPoseMatrix();

float* WebARKitTracker::getPoseMatrix2() { return _trackerImpl->getPoseMatrix2(); }

//float[3][4] WebARKitTracker::getPoseMatrix3() { return _trackerImpl->getPoseMatrix3(); }
//float (*WebARKitTracker::getPoseMatrix3())[3][4]) { return &_trackerImpl->getPoseMatrix3(); }

cv::Mat WebARKitTracker::getGLViewMatrix() { return _trackerImpl->getGLViewMatrix(); }

std::array<double, 16> WebARKitTracker::getCameraProjectionMatrix() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class WebARKitTracker {

float* getPoseMatrix2();

//float (*WebARKitTracker::getPoseMatrix3()[3][4]);

cv::Mat getGLViewMatrix();

std::array<double, 16> getCameraProjectionMatrix();
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