~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina6/tina-libs/tina/vision/visCalib_cam.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**********
  2  *
  3  * This file is part of the TINA Open Source Image Analysis Environment
  4  * henceforth known as TINA
  5  *
  6  * TINA is free software; you can redistribute it and/or modify
  7  * it under the terms of the GNU General Public License as
  8  * published by the Free Software Foundation.
  9  *
 10  * TINA is distributed in the hope that it will be useful,
 11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  * GNU General Public License for more details.
 14  *
 15  * You should have received a copy of the GNU General Public License
 16  * along with TINA; if not, write to the Free Software Foundation, Inc.,
 17  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 18  *
 19  * ANY users of TINA who require exemption from the existing licence must
 20  * negotiate a new licence with Dr. Neil.A.Thacker, the sole agent for
 21  * the University of Manchester.
 22  *
 23  **********
 24  *
 25  * Program :    TINA
 26  * File    :  $Source: /home/tina/cvs/tina-libs/tina/vision/visCalib_cam.c,v $
 27  * Date    :  $Date: 2004/02/13 12:30:33 $
 28  * Version :  $Revision: 1.4 $
 29  * CVS Id  :  $Id: visCalib_cam.c,v 1.4 2004/02/13 12:30:33 neil Exp $
 30  *
 31  * Author  : Legacy TINA
 32  *
 33  * Notes :
 34  *
 35  *********
 36 */
 37 
 38 #include "visCalib_cam.h"
 39 
 40 #if HAVE_CONFIG_H
 41   #include <config.h>
 42 #endif
 43 
 44 #include <math.h>
 45 #include <float.h>
 46 #include <limits.h>
 47 #include <tina/sys/sysDef.h>
 48 #include <tina/sys/sysPro.h>
 49 #include <tina/math/mathDef.h>
 50 #include <tina/geometry/geomDef.h>
 51 #include <tina/geometry/geomPro.h>
 52 #include <tina/vision/vis_CalibPro.h>
 53 
 54 static double scale_init = 0.04, c_test1 = 0.00001, c_test2 = 0.1;
 55 static double accuracy = 1.0;
 56 
 57 void    cam_cal_smplx_params_set(double s_init, double c1, double c2, double a)
 58 {
 59     scale_init = s_init;
 60     c_test1 = c1;
 61     c_test2 = c2;
 62     accuracy = a;
 63 }
 64 
 65 static void format_params(char *string, double *a, int n)
 66 {
 67     int     i;
 68 
 69     format(string);
 70     for (i = 0; i < n; i++)
 71         format("%f ", a[i]);
 72     format("\n");
 73 }
 74 
 75 static Camera *cal_cam;
 76 static int cal_mask;
 77 static List *cal_data;
 78 static Vec3 *(*cal_get_3d) ();
 79 static Vec2 *(*cal_get_pix) ();
 80 static Covar *cal_in_cov;
 81 
 82 static double pixchisq(int n_par, double *a)
 83 /* BUG n_par unused */
 84 
 85 
 86 {
 87     double  chisq = DBL_MAX;
 88     double *f = NULL;
 89     int     n_data = INT_MAX;
 90 
 91     (void) store_camera_int(cal_mask, a + 6, cal_cam);
 92     if (store_camera_ext(a, cal_cam))
 93     {
 94         chisq = camerror(&n_data, f, cal_cam, cal_data, cal_get_pix, cal_get_3d, accuracy);
 95         chisq += cam_reg(cal_in_cov, cal_mask, a);
 96     }
 97     return (chisq);
 98 }
 99 
100 double  cam_cal_simplex(Camera * cam, int mask, List * data, Vec3 * (*get_3d) ( /* ??? */ ), Vec2 * (*get_pix) ( /* ??? */ ), Covar * in_cov)
101 
102 
103 
104 
105 
106 /* inverse covarience */
107 {
108     double  chisq, chisq_old;
109     double *a;
110     int     n_par, i;
111 
112     if (data == NULL || cam == NULL)
113         return (0.0);
114 
115     cal_mask = mask;
116     cal_data = data;
117     cal_cam = cam;
118     cal_get_3d = get_3d;
119     cal_get_pix = get_pix;
120     cal_in_cov = in_cov;
121 
122     for (i = 0, n_par = 6; i < 16; i++)
123         if (mask & (1 << i))
124             n_par++;
125     a = (double *) ralloc((unsigned) n_par * sizeof(double));
126 
127     (void) conv_camera_int(mask, cam, a + 6);
128     (void) conv_camera_ext(cam, a);
129 
130     format_params("Initial camera parameters = ", a, n_par);
131 
132     chisq_old = pixchisq(n_par, a);
133     for (i = 0; i < 5; ++i)
134     {
135         chisq = simplexmin(n_par, a, scale_init, pixchisq, NULL, c_test1,
136                            (void (*) ()) format);
137         if (chisq_old - chisq < c_test2)
138             break;
139         chisq_old = chisq;
140     }
141 
142     format_params("Final camera parameters = ", a, n_par);
143 
144     (void) store_camera_int(mask, a + 6, cam);
145     (void) store_camera_ext(a, cam);
146     rfree((void *) a);
147     return (chisq);
148 }
149 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.