35 printf(
"[%5.1f, %5.1f, %5.1f] %f\n", bf[0], bf[1], bf[2], min);
36 for( j = -10; j <= 10; j++ ) {
38 for( i = -10; i <= 10; i++ ) {
41 if( error < min ) { bf[0] = factor[0]; bf[1] = factor[1];
42 bf[2] = factor[2]; min = error; }
44 printf(
"[%5.1f, %5.1f, %5.1f] %f\n", bf[0], bf[1], bf[2], min);
49 for( j = -10; j <= 10; j++ ) {
50 factor[1] = by + (
ARFloat)0.5 * j;
51 for( i = -10; i <= 10; i++ ) {
52 factor[0] = bx + (
ARFloat)0.5 * i;
54 if( error < min ) { bf[0] = factor[0]; bf[1] = factor[1];
55 bf[2] = factor[2]; min = error; }
57 printf(
"[%5.1f, %5.1f, %5.1f] %f\n", bf[0], bf[1], bf[2], min);
60 dist_factor[0] = bf[0];
61 dist_factor[1] = bf[1];
62 dist_factor[2] = bf[2];
76 olen = dist_factor[0];
77 ARToolKitPlus::Tracker::arParamObserv2Ideal( dist_factor, ox, oy, &ix, &iy );
78 ilen = dist_factor[0] - ix;
79 printf(
"Olen = %f, Ilen = %f\n", olen, ilen);
82 if( sf1 < sf ) sf = sf1;
87 olen = xsize - dist_factor[0];
88 ARToolKitPlus::Tracker::arParamObserv2Ideal( dist_factor, ox, oy, &ix, &iy );
89 ilen = ix - dist_factor[0];
90 printf(
"Olen = %f, Ilen = %f\n", olen, ilen);
93 if( sf1 < sf ) sf = sf1;
98 olen = dist_factor[1];
99 ARToolKitPlus::Tracker::arParamObserv2Ideal( dist_factor, ox, oy, &ix, &iy );
100 ilen = dist_factor[1] - iy;
101 printf(
"Olen = %f, Ilen = %f\n", olen, ilen);
104 if( sf1 < sf ) sf = sf1;
109 olen = ysize - dist_factor[1];
110 ARToolKitPlus::Tracker::arParamObserv2Ideal( dist_factor, ox, oy, &ix, &iy );
111 ilen = iy - dist_factor[1];
112 printf(
"Olen = %f, Ilen = %f\n", olen, ilen);
115 if( sf1 < sf ) sf = sf1;
118 if( sf == 0.0 ) sf = 1.0;
128 dist_factor[2] = 0.0;
132 for( i = -100; i < 200; i+=10 ) {
135 if( err < min ) { min = err; f = dist_factor[2]; }
139 for( i = -10; i <= 10; i++ ) {
140 dist_factor[2] = fb + i;
143 if( err < min ) { min = err; f = dist_factor[2]; }
147 for( i = -10; i <= 10; i++ ) {
148 dist_factor[2] = fb + (
ARFloat)0.1 * i;
151 if( err < min ) { min = err; f = dist_factor[2]; }
169 if( x ==
NULL || y ==
NULL ) exit(0);
173 for( i = 0; i < patt->
loop_num; i++ ) {
174 for( j = 0; j < patt->
v_num; j++ ) {
175 for( k = 0; k < patt->
h_num; k++ ) {
183 for( j = 0; j < patt->
h_num; j++ ) {
184 for( k = 0; k < patt->
v_num; k++ ) {
192 for( j = 3 - patt->
v_num; j < patt->h_num - 2; j++ ) {
194 for( k = 0; k < patt->
v_num; k++ ) {
196 if( l < 0 || l >= patt->
h_num )
continue;
205 for( j = 2; j < patt->
h_num + patt->
v_num - 3; j++ ) {
207 for( k = 0; k < patt->
v_num; k++ ) {
209 if( l < 0 || l >= patt->
h_num )
continue;
238 for( i = 0; i < num; i++ ) {
239 ARToolKitPlus::Tracker::arParamObserv2Ideal( dist_factor, x[i], y[i],
240 &(input->
m[i*2+0]), &(input->
m[i*2+1]) );
242 if( ARToolKitPlus::Tracker::arMatrixPCA(input, evec, ev, mean) < 0 ) exit(0);
245 c = -(a*mean->
v[0] + b*mean->
v[1]);
248 for( i = 0; i < num; i++ ) {
249 error += (a*input->
m[i*2+0] + b*input->
m[i*2+1] + c)
250 * (a*input->
m[i*2+0] + b*input->
m[i*2+1] + c);
252 error /= (a*a + b*b);
void calc_distortion(CALIB_PATT_T *patt, int xsize, int ysize, ARFloat dist_factor[4])
TFSIMD_FORCE_INLINE const tfScalar & y() const
static ARFloat get_fitting_error(CALIB_PATT_T *patt, ARFloat dist_factor[4])
static ARFloat calc_distortion2(CALIB_PATT_T *patt, ARFloat dist_factor[4])
TFSIMD_FORCE_INLINE const tfScalar & x() const
CALIB_COORD_T * point[LOOP_MAX]
static ARFloat check_error(ARFloat *x, ARFloat *y, int num, ARFloat dist_factor[4])
static ARFloat get_size_factor(ARFloat dist_factor[4], int xsize, int ysize)