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

Linux Cross Reference
Tina6/tina-libs/tina/vision/visModel_smplx.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/visModel_smplx.c,v $
 27 * Date    :  $Date: 2008/10/02 11:53:05 $
 28 * Version :  $Revision: 1.5 $
 29 * CVS Id  :  $Id: visModel_smplx.c,v 1.5 2008/10/02 11:53:05 neil Exp $
 30 *
 31 * Notes   :
 32 *
 33 *
 34 *
 35 *********
 36 */
 37 
 38 #include "visModel_smplx.h"
 39 
 40 #if HAVE_CONFIG_H
 41 #include <config.h>
 42 #endif
 43 
 44 #include <stdio.h>
 45 #include <limits.h>
 46 #include <float.h>
 47 
 48 #include <tina/sys/sysDef.h>
 49 #include <tina/sys/sysPro.h>
 50 #include <tina/math/mathDef.h>
 51 #include <tina/math/mathPro.h>
 52 #include <tina/geometry/geomPro.h>
 53 #include <tina/geometry/geomDef.h>
 54 #include <tina/vision/visDef.h>
 55 #include <tina/vision/visPro.h>
 56 
 57 
 58 static double   scale_init = 0.04, c_test1 = 0.00001, c_test2 = 0.1;
 59 static double   accuracy = 1.0;
 60 static int      cal_mask;
 61 static List    *cal_data, *cal_cliche_info;
 62 static Covar   *cal_in_cov;
 63 static Model_smplx *ms=NULL; 
 64 
 65 
 66 void   model_cal_smplx_params_set(double s_init, double c1, double c2, double a)
 67 {
 68         scale_init = s_init;
 69         c_test1 = c1;
 70         c_test2 = c2;
 71         accuracy = a;
 72 }
 73 
 74 static void     format_params(char *string, double *a, int n)
 75 {
 76         int             i;
 77 
 78         format(string);
 79         for (i = 0; i < n; i++)
 80                 format("%f ", a[i]);
 81         format("\n");
 82 }
 83 
 84 
 85 static double   pixchisq(int n_par, double *a)
 86 /* n_par unused */
 87 {
 88         double          chisq = DBL_MAX;
 89         double         *f = NULL;
 90         int             n_data = INT_MAX;
 91 
 92         (void) store_camera_int(cal_mask, a + 6, ms->cam);
 93         if (store_camera_ext(a, ms->cam))
 94         {
 95                 chisq = -pot_camerror(&n_data, f, ms, accuracy, cal_cliche_info);
 96                 chisq += cam_reg(cal_in_cov, cal_mask, a);
 97         }
 98         return (chisq);
 99 }
100 
101 double          model_cal_simplex(Model_smplx *modsmplx, int mask, List * data, Covar * in_cov, List *cliche_spec)
102 {
103         double          chisq, chisq_old;
104         double         *a;
105         int             n_par, i;
106         Transform3 *cam_trans;
107         Camera *cam;
108 
109         if (data == NULL || modsmplx == NULL)
110                 return (0.0);
111         cal_mask = mask;
112         cal_data = data;
113         cal_in_cov = in_cov;
114         cal_cliche_info = cliche_spec;
115         ms = modsmplx;
116         cam = ms->cam;
117         if (cam == NULL)
118                 return (0.0);
119 
120         for (i = 0, n_par = 6; i < 16; i++)
121                 if (mask & (1 << i))
122                         n_par++;
123         a = (double *) ralloc((unsigned) n_par * sizeof(double));
124 
125         (void) conv_camera_int(mask, cam, a + 6);
126         (void) conv_camera_ext(cam, a);
127 
128         format_params("Initial camera parameters = ", a, n_par);
129         chisq_old = pixchisq(n_par, a);
130 
131         for (i = 0; i < 5; ++i)
132         {
133                 chisq = simplexmin(n_par, a, scale_init, pixchisq, NULL, c_test1,
134                                    (void (*) ()) format);
135                 if (chisq_old - chisq < c_test2)
136                 break;
137                 chisq_old = chisq;
138 
139         }
140 
141         chisq = pixchisq(n_par, a);
142 
143         cam_trans = cam->transf;
144 
145         format_params("Final camera parameters = ", a, n_par);
146 
147         (void) store_camera_int(mask, a + 6, cam);
148         (void) store_camera_ext(a, cam);
149         rfree((void *) a);
150         return (chisq);
151 }
152 

~ [ 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.