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

Reuse p and R memory from params in apriltag_pose #197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 8 additions & 4 deletions apriltag_pose.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ double orthogonal_iteration(matd_t** v, matd_t** p, matd_t** t, matd_t** R, int
matd_destroy(M2_update);
}
matd_scale_inplace(M2, 1.0/n_points);
matd_destroy(*t);
*t = matd_multiply(M1_inv, M2);
matd_t *tmp1 = matd_multiply(M1_inv, M2);
matd_set_data(*t, tmp1->data);
matd_destroy(tmp1);

matd_destroy(M2);

// Calculate rotation.
Expand All @@ -99,8 +101,10 @@ double orthogonal_iteration(matd_t** v, matd_t** p, matd_t** t, matd_t** R, int
}
matd_svd_t M3_svd = matd_svd(M3);
matd_destroy(M3);
matd_destroy(*R);
*R = matd_op("M*M'", M3_svd.U, M3_svd.V);
matd_t *tmp2 = matd_op("M*M'", M3_svd.U, M3_svd.V);
matd_set_data(*R, tmp2->data);
matd_destroy(tmp2);

double R_det = matd_det(*R);
if (R_det < 0) {
matd_put(*R, 0, 2, - matd_get(*R, 0, 2));
Expand Down