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

Relative error #189

Open
wants to merge 2 commits into
base: master
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
19 changes: 15 additions & 4 deletions liboptv/src/orientation.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <string.h>
#include <math.h>

#define NUM_ITER 80
#define NUM_ITER 2000
#define POS_INF 1E20
#define CONVERGENCE 0.00001

Expand Down Expand Up @@ -254,6 +254,7 @@ double* orient (Calibration* cal_in, control_par *cpar, int nfix, vec3d fix[],
int i,j,n, itnum, stopflag, n_obs=0, maxsize;

double ident[IDT], XPX[NPAR][NPAR], XPy[NPAR], beta[NPAR], omega=0;
double old_beta[NPAR],diff;
double xp, yp, xpd, ypd, xc, yc, r, qq, p, sumP;

int numbers;
Expand Down Expand Up @@ -519,7 +520,12 @@ double* orient (Calibration* cal_in, control_par *cpar, int nfix, vec3d fix[],

stopflag = 1;
for (i = 0; i < numbers; i++) {
if (fabs (beta[i]) > CONVERGENCE) stopflag = 0;
diff = fabs(old_beta[i]-beta[i]);
if ( (fabs (beta[i]) > CONVERGENCE) & (diff/beta[i] > 0.01) & (fabs(diff/beta[i] - 2.0) > 0.01) ) {
printf("failing beta[%d] = %f, diff/beta: %f\n",i,beta[i],diff/beta[i]);
stopflag = 0;
}
old_beta[i] = beta[i];
}

if ( ! flags->ccflag) beta[6] = 0.0;
Expand Down Expand Up @@ -581,11 +587,13 @@ double* orient (Calibration* cal_in, control_par *cpar, int nfix, vec3d fix[],
free(Xh);

if (stopflag){
printf("updated calibration\n");
rotation_matrix(&(cal->ext_par));
memcpy(cal_in, cal, sizeof (Calibration));
return resi;
}
else {
printf("failed calibration\n");
free(resi);
return NULL;
}
Expand Down Expand Up @@ -677,8 +685,11 @@ int raw_orient (Calibration* cal, control_par *cpar, int nfix, vec3d fix[], targ

stopflag = 1;
for (i = 0; i < 6; i++) {
if (fabs (beta[i]) > 0.1 )
stopflag = 0;
if (fabs (beta[i]) > 0.1 ){
// printf("raw beta[%d]=%f failed\n",i,beta[i]);
stopflag = 0;
}

}

cal->ext_par.x0 += beta[0];
Expand Down
3 changes: 2 additions & 1 deletion py_bind/optv/orientation.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,9 @@ def full_calibration(Calibration cal,
orip[0].p2flag = (1 if 'p2' in flags else 0)
orip[0].scxflag = (1 if 'scale' in flags else 0)
orip[0].sheflag = (1 if 'shear' in flags else 0)
orip[0].interfflag = 0 # This also solves for the glass, I'm skipping it.
orip[0].interfflag = (1 if 'shear' in flags else 0) # 0 # This also solves for the glass, I'm skipping it.


err_est = np.empty((NPAR + 1) * sizeof(double))
residuals = orient(cal._calibration, cparam._control_par, len(ref_pts),
ref_coord, img_pts._tarr, orip, <double *>err_est.data)
Expand Down