compute_prob1.cpp
Go to the documentation of this file.
00001 /*
00002  * compute_prob1.cpp
00003  *
00004  * Code generation for function 'compute_prob1'
00005  *
00006  * C source code generated on: Wed Jul 24 16:11:35 2013
00007  *
00008  */
00009 
00010 /* Include files */
00011 #include "rt_nonfinite.h"
00012 #include "Optimal_affine_tracking_3d16_fast_realtime.h"
00013 #include "compute_prob1.h"
00014 #include "norm.h"
00015 #include "estimateRigidTransform.h"
00016 #include "mean.h"
00017 #include "image_warping.h"
00018 #include "mldivide.h"
00019 #include "expm.h"
00020 #include "randn.h"
00021 #include "chol.h"
00022 #include "sum.h"
00023 #include "diag.h"
00024 #include "log.h"
00025 #include "eig.h"
00026 #include "mrdivide.h"
00027 #include "Optimal_affine_tracking_3d16_fast_realtime_emxutil.h"
00028 #include "removeOutliers.h"
00029 #include "round.h"
00030 #include "resampling.h"
00031 #include "exp.h"
00032 #include "repmat.h"
00033 #include "gradient.h"
00034 #include "Optimal_affine_tracking_3d16_fast_realtime_rtwutil.h"
00035 
00036 /* Type Definitions */
00037 
00038 /* Named Constants */
00039 
00040 /* Variable Declarations */
00041 
00042 /* Variable Definitions */
00043 
00044 /* Function Declarations */
00045 static void b_eml_li_find(const boolean_T x[25], int32_T y_data[25], int32_T
00046   y_size[1]);
00047 static int32_T compute_nones(const boolean_T x[1296]);
00048 static real_T rt_remd_snf(real_T u0, real_T u1);
00049 
00050 /* Function Definitions */
00051 static void b_eml_li_find(const boolean_T x[25], int32_T y_data[25], int32_T
00052   y_size[1])
00053 {
00054   int32_T k;
00055   int32_T i;
00056   k = 0;
00057   for (i = 0; i < 25; i++) {
00058     if (x[i]) {
00059       k++;
00060     }
00061   }
00062 
00063   y_size[0] = k;
00064   k = 0;
00065   for (i = 0; i < 25; i++) {
00066     if (x[i]) {
00067       y_data[k] = i + 1;
00068       k++;
00069     }
00070   }
00071 }
00072 
00073 static int32_T compute_nones(const boolean_T x[1296])
00074 {
00075   int32_T k;
00076   int32_T i;
00077   k = 0;
00078   for (i = 0; i < 1296; i++) {
00079     if (x[i]) {
00080       k++;
00081     }
00082   }
00083 
00084   return k;
00085 }
00086 
00087 static real_T rt_remd_snf(real_T u0, real_T u1)
00088 {
00089   real_T y;
00090   boolean_T b_y;
00091   boolean_T c_y;
00092   real_T tr;
00093   if (u1 < 0.0) {
00094     y = ceil(u1);
00095   } else {
00096     y = floor(u1);
00097   }
00098 
00099   b_y = ((!rtIsNaN(u0)) && (!rtIsInf(u0)));
00100   c_y = ((!rtIsNaN(u1)) && (!rtIsInf(u1)));
00101   if ((u1 != 0.0) && (u1 != y) && (b_y && c_y)) {
00102     tr = u0 / u1;
00103     if (fabs(tr - rt_roundd_snf(tr)) <= DBL_EPSILON * fabs(tr)) {
00104       y = 0.0;
00105     } else {
00106       y = fmod(u0, u1);
00107     }
00108   } else {
00109     y = fmod(u0, u1);
00110   }
00111 
00112   return y;
00113 }
00114 
00115 void compute_prob1(real_T X_par[2250000], real_T X_par_pred[2250000], real_T
00116                    AR_velocity[2250000], const real_T dw_dp[15552], real_T t,
00117                    real_T center_x, real_T center_y, const real_T Ixyz[504063],
00118                    const real_T point_matrix[3888], real_T mean_img[3888],
00119                    real_T tracked_images[38880000], real_T Aff_matrix[9], real_T
00120                    centroid[3])
00121 {
00122   static real_T warped_img[3888];
00123   static real_T frame[504063];
00124   static real_T b_Ixyz[168021];
00125   static real_T c_Ixyz[168021];
00126   int32_T ix;
00127   int32_T i26;
00128   static real_T ext_frame[1008126];
00129   static real_T ext_grad_x[336042];
00130   static real_T ext_grad_y[336042];
00131   real_T rigid_transform_par[400];
00132   real_T dist1Array[25];
00133   int32_T par;
00134   creal_T LOGMX[9];
00135   creal_T X_par_temp[9];
00136   creal_T dcv0[3];
00137   creal_T dcv1[9];
00138   creal_T b_X_par_temp[9];
00139   creal_T c_X_par_temp[9];
00140   real_T d;
00141   real_T s;
00142   int32_T i;
00143   real_T b_center_x[2];
00144   static const int8_T iv10[3] = { 0, 0, 1 };
00145 
00146   boolean_T zero_ind_z[1296];
00147   boolean_T b_zero_ind_z;
00148   boolean_T c_zero_ind_z[1296];
00149   int32_T tmp_size[1];
00150   int32_T tmp_data[1296];
00151   int32_T b_tmp_size[1];
00152   int32_T b_tmp_data[1296];
00153   real_T warped_grad_x3[1296];
00154   int32_T warped_img_size[1];
00155   int32_T b_warped_img_size[1];
00156   int32_T c_warped_img_size[1];
00157   real_T warped_grad_y3[1296];
00158   real_T img_grad[2592];
00159   real_T transform[16];
00160   static real_T b_warped_img[5184];
00161   static real_T b_transform[5184];
00162   static creal_T a[7776];
00163   static real_T b_a[7776];
00164   real_T c_a[2592];
00165   creal_T sum_jacobian[6];
00166   creal_T increment[6];
00167   creal_T d_X_par_temp[6];
00168   creal_T e_X_par_temp[6];
00169   creal_T dcv2[6];
00170   creal_T dcv3[6];
00171   creal_T f_X_par_temp[36];
00172   static creal_T d_a[7776];
00173   static const real_T dv13[36] = { 0.00066666666666666675, 0.0, 0.0, 0.0, 0.0,
00174     0.0, 0.0, 2.6666666666666667E-5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
00175     0.002666666666666667, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.6666666666666667E-5,
00176     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.2666666666666666, 0.0, 0.0, 0.0, 0.0, 0.0,
00177     0.0, 3.2666666666666666 };
00178 
00179   creal_T dcv4[36];
00180   creal_T sigma_12[6];
00181   creal_T y[6];
00182   real_T sigma_22_re;
00183   real_T sigma_22_im;
00184   real_T b;
00185   real_T sigma_12_re;
00186   real_T brm;
00187   static const int8_T b_b[9] = { 0, 0, 0, 0, 0, 0, 0, 1, 0 };
00188 
00189   static const int8_T c_b[9] = { 0, 0, 0, 0, 0, 0, 1, 0, 0 };
00190 
00191   static const int8_T d_b[9] = { 0, 1, 0, 1, 0, 0, 0, 0, 0 };
00192 
00193   static const int8_T e_b[9] = { 0, 1, 0, -1, 0, 0, 0, 0, 0 };
00194 
00195   static const int8_T f_b[9] = { 1, 0, 0, 0, -1, 0, 0, 0, 0 };
00196 
00197   static const int8_T g_b[9] = { 1, 0, 0, 0, 1, 0, 0, 0, 0 };
00198 
00199   real_T CH[36];
00200   real_T h_b[6];
00201   real_T random_coeff[6];
00202   real_T b_random_coeff[9];
00203   real_T i_b[9];
00204   int32_T d_warped_img_size[1];
00205   int32_T e_warped_img_size[1];
00206   int32_T f_warped_img_size[1];
00207   static real_T c_transform[5184];
00208   static real_T warped_img_tr[3888];
00209   static real_T b_warped_img_tr[3888];
00210   boolean_T b_dist1Array[25];
00211   int32_T c_tmp_data[25];
00212   real_T outindex[25];
00213   real_T b_X_par_pred[225];
00214   real_T b_rigid_transform_par[400];
00215   int32_T itmp;
00216   boolean_T exitg1;
00217   real_T mean_log[4];
00218   real_T c_X_par_pred[4];
00219   real_T b_X_par[4];
00220   real_T b_LOGMX[4];
00221   creal_T D[4];
00222   creal_T V[4];
00223   creal_T dcv5[2];
00224   creal_T b_V[4];
00225   real_T c_X_par[50];
00226   real_T mean_trans[2];
00227   int32_T g_warped_img_size[1];
00228   int32_T h_warped_img_size[1];
00229   int32_T i_warped_img_size[1];
00230   static real_T c_rigid_transform_par[5184];
00231   emxArray_real_T *b_tracked_images;
00232   emxArray_real_T *c_tracked_images;
00233   emxArray_real_T *d_tracked_images;
00234   memset(&warped_img[0], 0, 3888U * sizeof(real_T));
00235   memset(&frame[0], 0, 504063U * sizeof(real_T));
00236 //#pragma omp for schedule (dynamic, 8)
00237   for (ix = 0; ix < 441; ix++) {
00238     for (i26 = 0; i26 < 381; i26++) {
00239       frame[336042 + (i26 + 381 * ix)] = Ixyz[336042 + (i26 + 381 * ix)];
00240       b_Ixyz[i26 + 381 * ix] = (Ixyz[i26 + 381 * ix] + 2.0) * (real_T)(frame
00241         [336042 + (i26 + 381 * ix)] != 0.0);
00242       frame[i26 + 381 * ix] = b_Ixyz[i26 + 381 * ix];
00243       c_Ixyz[i26 + 381 * ix] = (Ixyz[168021 + (i26 + 381 * ix)] + 2.0) * (real_T)
00244         (frame[336042 + (i26 + 381 * ix)] != 0.0);
00245       frame[168021 + (i26 + 381 * ix)] = c_Ixyz[i26 + 381 * ix];
00246     }
00247   }
00248 
00249   repmat(frame, ext_frame);
00250   gradient(*(real_T (*)[168021])&frame[336042], b_Ixyz, c_Ixyz);
00251   b_repmat(c_Ixyz, ext_grad_x);
00252   b_repmat(b_Ixyz, ext_grad_y);
00253 //#pragma omp for schedule (dynamic, 80)
00254   for (par = 0; par < 25; par++) {
00255     eig(*(real_T (*)[9])&AR_velocity[9 * par + 225 * ((int32_T)(t - 1.0) - 1)],
00256         X_par_temp, LOGMX);
00257 //#pragma omp for schedule (dynamic, 8)
00258     for (ix = 0; ix < 3; ix++) {
00259       dcv0[ix] = LOGMX[ix << 2];
00260     }
00261 
00262     b_log(dcv0);
00263     diag(dcv0, dcv1);
00264 //#pragma omp for schedule (dynamic, 8)
00265     for (ix = 0; ix < 3; ix++) {
00266       for (i26 = 0; i26 < 3; i26++) {
00267         b_X_par_temp[i26 + 3 * ix].re = X_par_temp[ix + 3 * i26].re;
00268         b_X_par_temp[i26 + 3 * ix].im = -X_par_temp[ix + 3 * i26].im;
00269       }
00270     }
00271 //#pragma omp for schedule (dynamic, 8)
00272     for (ix = 0; ix < 3; ix++) {
00273       for (i26 = 0; i26 < 3; i26++) {
00274         d = 0.0;
00275         s = 0.0;
00276         for (i = 0; i < 3; i++) {
00277           d += X_par_temp[i26 + 3 * i].re * dcv1[i + 3 * ix].re - X_par_temp[i26
00278             + 3 * i].im * dcv1[i + 3 * ix].im;
00279           s += X_par_temp[i26 + 3 * i].re * dcv1[i + 3 * ix].im + X_par_temp[i26
00280             + 3 * i].im * dcv1[i + 3 * ix].re;
00281         }
00282 
00283         c_X_par_temp[ix + 3 * i26].re = d;
00284         c_X_par_temp[ix + 3 * i26].im = -s;
00285       }
00286     }
00287 
00288     mldivide(b_X_par_temp, c_X_par_temp, dcv1);
00289 //#pragma omp for schedule (dynamic, 8)
00290     for (ix = 0; ix < 3; ix++) {
00291       for (i26 = 0; i26 < 3; i26++) {
00292         LOGMX[i26 + 3 * ix].re = dcv1[ix + 3 * i26].re;
00293         LOGMX[i26 + 3 * ix].im = -dcv1[ix + 3 * i26].im;
00294       }
00295     }
00296 //#pragma omp for schedule (dynamic, 8)
00297     for (ix = 0; ix < 9; ix++) {
00298       c_X_par_temp[ix].re = 0.5 * LOGMX[ix].re;
00299       c_X_par_temp[ix].im = 0.5 * LOGMX[ix].im;
00300     }
00301 
00302     expm(c_X_par_temp, LOGMX);
00303 //#pragma omp for schedule (dynamic, 8)
00304     for (ix = 0; ix < 3; ix++) {
00305       for (i26 = 0; i26 < 3; i26++) {
00306         c_X_par_temp[i26 + 3 * ix].re = X_par[((i26 + 3 * ix) + 9 * par) + 225 *
00307           ((int32_T)(t - 1.0) - 1)];
00308         c_X_par_temp[i26 + 3 * ix].im = 0.0;
00309       }
00310     }
00311 //#pragma omp for schedule (dynamic, 8)
00312     for (ix = 0; ix < 3; ix++) {
00313       for (i26 = 0; i26 < 3; i26++) {
00314         X_par_temp[ix + 3 * i26].re = 0.0;
00315         X_par_temp[ix + 3 * i26].im = 0.0;
00316         for (i = 0; i < 3; i++) {
00317           X_par_temp[ix + 3 * i26].re += c_X_par_temp[ix + 3 * i].re * LOGMX[i +
00318             3 * i26].re - 0.0 * LOGMX[i + 3 * i26].im;
00319           X_par_temp[ix + 3 * i26].im += c_X_par_temp[ix + 3 * i].re * LOGMX[i +
00320             3 * i26].im + 0.0 * LOGMX[i + 3 * i26].re;
00321         }
00322       }
00323     }
00324 
00325     b_center_x[0] = center_x;
00326     b_center_x[1] = center_y;
00327 //#pragma omp for schedule (dynamic, 8)
00328     for (ix = 0; ix < 2; ix++) {
00329       for (i26 = 0; i26 < 2; i26++) {
00330         Aff_matrix[i26 + 3 * ix] = X_par_temp[i26 + 3 * ix].re;
00331       }
00332     }
00333 //#pragma omp for schedule (dynamic, 8)
00334     for (ix = 0; ix < 2; ix++) {
00335       Aff_matrix[6 + ix] = X_par_temp[6 + ix].re + b_center_x[ix];
00336     }
00337 
00338 //#pragma omp for schedule (dynamic, 8)
00339     for (ix = 0; ix < 3; ix++) {
00340       Aff_matrix[2 + 3 * ix] = (real_T)iv10[ix];
00341     }
00342 
00343     /*              Aff_matrix = real([X_par_tempArray(1:2,1:2,par) X_par_tempArray(1:2,3,par)+[center_x;center_y];0 0 1]);  % AR-based state dynamics model (infinitesimal constant velocity model) eq 8,9 */
00344     b_image_warping(*(real_T (*)[336042])&ext_frame[0], Aff_matrix, point_matrix,
00345                     *(real_T (*)[1296])&warped_img[0]);
00346     b_image_warping(*(real_T (*)[336042])&ext_frame[336042], Aff_matrix,
00347                     point_matrix, *(real_T (*)[1296])&warped_img[1296]);
00348     b_image_warping(*(real_T (*)[336042])&ext_frame[672084], Aff_matrix,
00349                     point_matrix, *(real_T (*)[1296])&warped_img[2592]);
00350 
00351     /*             %% replace zeros with average values */
00352 //#pragma omp for schedule (dynamic, 8)
00353     for (ix = 0; ix < 1296; ix++) {
00354       b_zero_ind_z = (warped_img[2592 + ix] == 0.0);
00355       zero_ind_z[ix] = !b_zero_ind_z;
00356       c_zero_ind_z[ix] = b_zero_ind_z;
00357     }
00358 
00359     eml_li_find(c_zero_ind_z, tmp_data, tmp_size);
00360     eml_li_find(zero_ind_z, b_tmp_data, b_tmp_size);
00361     warped_img_size[0] = b_tmp_size[0];
00362     i = b_tmp_size[0] - 1;
00363 //#pragma omp for schedule (dynamic, 8)
00364     for (ix = 0; ix <= i; ix++) {
00365       warped_grad_x3[ix] = warped_img[b_tmp_data[ix] + 2591];
00366     }
00367 
00368     d = mean(warped_grad_x3, warped_img_size);
00369     i = tmp_size[0] - 1;
00370 //#pragma omp for schedule (dynamic, 8)
00371     for (ix = 0; ix <= i; ix++) {
00372       warped_img[tmp_data[ix] + 2591] = d;
00373     }
00374 
00375     eml_li_find(c_zero_ind_z, tmp_data, tmp_size);
00376 //#pragma omp for schedule (dynamic, 8)
00377     for (i = 0; i < 1296; i++) {
00378       zero_ind_z[i] = !c_zero_ind_z[i];
00379     }
00380 
00381     eml_li_find(zero_ind_z, b_tmp_data, b_tmp_size);
00382     b_warped_img_size[0] = b_tmp_size[0];
00383     i = b_tmp_size[0] - 1;
00384 //#pragma omp for schedule (dynamic, 8)
00385     for (ix = 0; ix <= i; ix++) {
00386       warped_grad_x3[ix] = warped_img[b_tmp_data[ix] - 1];
00387     }
00388 
00389     d = mean(warped_grad_x3, b_warped_img_size);
00390     i = tmp_size[0] - 1;
00391 //#pragma omp for schedule (dynamic, 8)
00392     for (ix = 0; ix <= i; ix++) {
00393       warped_img[tmp_data[ix] - 1] = d;
00394     }
00395 
00396     eml_li_find(c_zero_ind_z, tmp_data, tmp_size);
00397 //#pragma omp for schedule (dynamic, 8)
00398     for (i = 0; i < 1296; i++) {
00399       zero_ind_z[i] = !c_zero_ind_z[i];
00400     }
00401 
00402     eml_li_find(zero_ind_z, b_tmp_data, b_tmp_size);
00403     c_warped_img_size[0] = b_tmp_size[0];
00404     i = b_tmp_size[0] - 1;
00405 //#pragma omp for schedule (dynamic, 8)
00406     for (ix = 0; ix <= i; ix++) {
00407       warped_grad_x3[ix] = warped_img[b_tmp_data[ix] + 1295];
00408     }
00409 
00410     d = mean(warped_grad_x3, c_warped_img_size);
00411     i = tmp_size[0] - 1;
00412 //#pragma omp for schedule (dynamic, 8)
00413     for (ix = 0; ix <= i; ix++) {
00414       warped_img[tmp_data[ix] + 1295] = d;
00415     }
00416 
00417     /*             %% */
00418     b_image_warping(ext_grad_x, Aff_matrix, point_matrix, warped_grad_x3);
00419     b_image_warping(ext_grad_y, Aff_matrix, point_matrix, warped_grad_y3);
00420 //#pragma omp for schedule (dynamic, 8)
00421     for (ix = 0; ix < 1296; ix++) {
00422       img_grad[ix] = warped_grad_x3[ix];
00423       img_grad[1296 + ix] = warped_grad_y3[ix];
00424     }
00425 
00426     /*             %% compute rigid transform */
00427     estimateRigidTransform(mean_img, warped_img, transform);
00428 //#pragma omp for schedule (dynamic, 8)
00429     for (ix = 0; ix < 1296; ix++) {
00430       for (i26 = 0; i26 < 3; i26++) {
00431         b_warped_img[i26 + (ix << 2)] = warped_img[ix + 1296 * i26];
00432       }
00433 
00434       b_warped_img[3 + (ix << 2)] = 1.0;
00435 //#pragma omp for schedule (dynamic, 8)
00436       for (i26 = 0; i26 < 4; i26++) {
00437         b_transform[ix + 1296 * i26] = 0.0;
00438         for (i = 0; i < 4; i++) {
00439           b_transform[ix + 1296 * i26] += transform[i26 + (i << 2)] *
00440             b_warped_img[i + (ix << 2)];
00441         }
00442       }
00443     }
00444 //#pragma omp for schedule (dynamic, 8)
00445     for (ix = 0; ix < 1296; ix++) {
00446       warped_grad_x3[ix] = b_transform[2592 + ix] - mean_img[2592 + ix];
00447     }
00448 //#pragma omp for schedule (dynamic, 8)
00449     for (i = 0; i < 1296; i++) {
00450       d = 2.0 * warped_grad_x3[i];
00451       c_a[i] = d * img_grad[i];
00452       c_a[1296 + i] = d * img_grad[1296 + i];
00453       b_a[i] = c_a[i] * dw_dp[12 * i] + c_a[1296 + i] * dw_dp[1 + 12 * i];
00454       b_a[1296 + i] = c_a[i] * dw_dp[2 + 12 * i] + c_a[1296 + i] * dw_dp[3 + 12 *
00455         i];
00456       b_a[2592 + i] = c_a[i] * dw_dp[4 + 12 * i] + c_a[1296 + i] * dw_dp[5 + 12 *
00457         i];
00458       b_a[3888 + i] = c_a[i] * dw_dp[6 + 12 * i] + c_a[1296 + i] * dw_dp[7 + 12 *
00459         i];
00460       b_a[5184 + i] = c_a[i] * dw_dp[8 + 12 * i] + c_a[1296 + i] * dw_dp[9 + 12 *
00461         i];
00462       b_a[6480 + i] = c_a[i] * dw_dp[10 + 12 * i] + c_a[1296 + i] * dw_dp[11 +
00463         12 * i];
00464     }
00465 
00466     sum_jacobian[0] = X_par_temp[0];
00467     sum_jacobian[1] = X_par_temp[1];
00468     sum_jacobian[2] = X_par_temp[3];
00469     sum_jacobian[3] = X_par_temp[4];
00470     sum_jacobian[4].re = 0.0;
00471     sum_jacobian[4].im = 0.0;
00472     sum_jacobian[5].re = 0.0;
00473     sum_jacobian[5].im = 0.0;
00474     increment[0] = X_par_temp[0];
00475     increment[1] = X_par_temp[1];
00476     increment[2].re = -X_par_temp[3].re;
00477     increment[2].im = -X_par_temp[3].im;
00478     increment[3].re = -X_par_temp[4].re;
00479     increment[3].im = -X_par_temp[4].im;
00480     increment[4].re = 0.0;
00481     increment[4].im = 0.0;
00482     increment[5].re = 0.0;
00483     increment[5].im = 0.0;
00484     d_X_par_temp[0] = X_par_temp[3];
00485     d_X_par_temp[1] = X_par_temp[4];
00486     d_X_par_temp[2].re = -X_par_temp[0].re;
00487     d_X_par_temp[2].im = -X_par_temp[0].im;
00488     d_X_par_temp[3].re = -X_par_temp[1].re;
00489     d_X_par_temp[3].im = -X_par_temp[1].im;
00490     d_X_par_temp[4].re = 0.0;
00491     d_X_par_temp[4].im = 0.0;
00492     d_X_par_temp[5].re = 0.0;
00493     d_X_par_temp[5].im = 0.0;
00494     e_X_par_temp[0] = X_par_temp[3];
00495     e_X_par_temp[1] = X_par_temp[4];
00496     e_X_par_temp[2] = X_par_temp[0];
00497     e_X_par_temp[3] = X_par_temp[1];
00498     e_X_par_temp[4].re = 0.0;
00499     e_X_par_temp[4].im = 0.0;
00500     e_X_par_temp[5].re = 0.0;
00501     e_X_par_temp[5].im = 0.0;
00502     dcv2[0].re = 0.0;
00503     dcv2[0].im = 0.0;
00504     dcv2[1].re = 0.0;
00505     dcv2[1].im = 0.0;
00506     dcv2[2].re = 0.0;
00507     dcv2[2].im = 0.0;
00508     dcv2[3].re = 0.0;
00509     dcv2[3].im = 0.0;
00510     dcv2[4] = X_par_temp[0];
00511     dcv2[5] = X_par_temp[1];
00512     dcv3[0].re = 0.0;
00513     dcv3[0].im = 0.0;
00514     dcv3[1].re = 0.0;
00515     dcv3[1].im = 0.0;
00516     dcv3[2].re = 0.0;
00517     dcv3[2].im = 0.0;
00518     dcv3[3].re = 0.0;
00519     dcv3[3].im = 0.0;
00520     dcv3[4] = X_par_temp[3];
00521     dcv3[5] = X_par_temp[4];
00522 //#pragma omp for schedule (dynamic, 8)
00523     for (ix = 0; ix < 6; ix++) {
00524       for (i26 = 0; i26 < 1296; i26++) {
00525         d_a[i26 + 1296 * ix].re = b_a[i26 + 1296 * ix];
00526         d_a[i26 + 1296 * ix].im = 0.0;
00527       }
00528 
00529       f_X_par_temp[ix] = sum_jacobian[ix];
00530       f_X_par_temp[6 + ix] = increment[ix];
00531       f_X_par_temp[12 + ix] = d_X_par_temp[ix];
00532       f_X_par_temp[18 + ix] = e_X_par_temp[ix];
00533       f_X_par_temp[24 + ix] = dcv2[ix];
00534       f_X_par_temp[30 + ix] = dcv3[ix];
00535     }
00536 //#pragma omp for schedule (dynamic, 8)
00537     for (ix = 0; ix < 1296; ix++) {
00538       for (i26 = 0; i26 < 6; i26++) {
00539         a[ix + 1296 * i26].re = 0.0;
00540         a[ix + 1296 * i26].im = 0.0;
00541         for (i = 0; i < 6; i++) {
00542           a[ix + 1296 * i26].re += d_a[ix + 1296 * i].re * f_X_par_temp[i + 6 *
00543             i26].re - 0.0 * f_X_par_temp[i + 6 * i26].im;
00544           a[ix + 1296 * i26].im += d_a[ix + 1296 * i].re * f_X_par_temp[i + 6 *
00545             i26].im + 0.0 * f_X_par_temp[i + 6 * i26].re;
00546         }
00547       }
00548     }
00549 
00550     b_sum(a, sum_jacobian);
00551 //#pragma omp for schedule (dynamic, 8)
00552     /* eq 17 -> P */
00553     for (ix = 0; ix < 6; ix++) {
00554       for (i26 = 0; i26 < 6; i26++) {
00555         f_X_par_temp[i26 + 6 * ix].re = dv13[i26 + 6 * ix];
00556         f_X_par_temp[i26 + 6 * ix].im = 0.0;
00557       }
00558     }
00559 //#pragma omp for schedule (dynamic, 8)
00560     /* eq 17 -> P*J' */
00561     for (ix = 0; ix < 6; ix++) {
00562       sigma_12[ix].re = 0.0;
00563       sigma_12[ix].im = 0.0;
00564       for (i26 = 0; i26 < 6; i26++) {
00565         sigma_12[ix].re += f_X_par_temp[ix + 6 * i26].re * sum_jacobian[i26].re
00566           - 0.0 * -sum_jacobian[i26].im;
00567         sigma_12[ix].im += f_X_par_temp[ix + 6 * i26].re * -sum_jacobian[i26].im
00568           + 0.0 * sum_jacobian[i26].re;
00569       }
00570 //#pragma omp for schedule (dynamic, 8)
00571       for (i26 = 0; i26 < 6; i26++) {
00572         dcv4[i26 + 6 * ix].re = dv13[i26 + 6 * ix];
00573         dcv4[i26 + 6 * ix].im = 0.0;
00574       }
00575 
00576       y[ix].re = 0.0;
00577       y[ix].im = 0.0;
00578 //#pragma omp for schedule (dynamic, 8)
00579       for (i26 = 0; i26 < 6; i26++) {
00580         y[ix].re += sum_jacobian[i26].re * dcv4[i26 + 6 * ix].re -
00581           sum_jacobian[i26].im * 0.0;
00582         y[ix].im += sum_jacobian[i26].re * 0.0 + sum_jacobian[i26].im * dcv4[i26
00583           + 6 * ix].re;
00584       }
00585 
00586       increment[ix].re = sum_jacobian[ix].re;
00587       increment[ix].im = -sum_jacobian[ix].im;
00588     }
00589 
00590     sigma_22_re = 0.0;
00591     sigma_22_im = 0.0;
00592 //#pragma omp for schedule (dynamic, 8)
00593     for (i = 0; i < 6; i++) {
00594       sigma_22_re += y[i].re * increment[i].re - y[i].im * increment[i].im;
00595       sigma_22_im += y[i].re * increment[i].im + y[i].im * increment[i].re;
00596     }
00597 
00598     sigma_22_re++;
00599 
00600     /* eq 17 -> J*P*J'+R */
00601     b = -norm(warped_grad_x3);
00602 //#pragma omp for schedule (dynamic, 8)
00603     for (i = 0; i < 6; i++) {
00604       if (sigma_22_im == 0.0) {
00605         if (sigma_12[i].im == 0.0) {
00606           sigma_12_re = sigma_12[i].re / sigma_22_re;
00607           d = 0.0;
00608         } else if (sigma_12[i].re == 0.0) {
00609           sigma_12_re = 0.0;
00610           d = sigma_12[i].im / sigma_22_re;
00611         } else {
00612           sigma_12_re = sigma_12[i].re / sigma_22_re;
00613           d = sigma_12[i].im / sigma_22_re;
00614         }
00615       } else if (sigma_22_re == 0.0) {
00616         if (sigma_12[i].re == 0.0) {
00617           sigma_12_re = sigma_12[i].im / sigma_22_im;
00618           d = 0.0;
00619         } else if (sigma_12[i].im == 0.0) {
00620           sigma_12_re = 0.0;
00621           d = -(sigma_12[i].re / sigma_22_im);
00622         } else {
00623           sigma_12_re = sigma_12[i].im / sigma_22_im;
00624           d = -(sigma_12[i].re / sigma_22_im);
00625         }
00626       } else {
00627         brm = fabs(sigma_22_re);
00628         d = fabs(sigma_22_im);
00629         if (brm > d) {
00630           s = sigma_22_im / sigma_22_re;
00631           d = sigma_22_re + s * sigma_22_im;
00632           sigma_12_re = (sigma_12[i].re + s * sigma_12[i].im) / d;
00633           d = (sigma_12[i].im - s * sigma_12[i].re) / d;
00634         } else if (d == brm) {
00635           d = sigma_22_re > 0.0 ? 0.5 : -0.5;
00636           s = sigma_22_im > 0.0 ? 0.5 : -0.5;
00637           sigma_12_re = (sigma_12[i].re * d + sigma_12[i].im * s) / brm;
00638           d = (sigma_12[i].im * d - sigma_12[i].re * s) / brm;
00639         } else {
00640           s = sigma_22_re / sigma_22_im;
00641           d = sigma_22_im + s * sigma_22_re;
00642           sigma_12_re = (s * sigma_12[i].re + sigma_12[i].im) / d;
00643           d = (s * sigma_12[i].im - sigma_12[i].re) / d;
00644         }
00645       }
00646 
00647       increment[i].re = b * sigma_12_re;
00648       increment[i].im = b * d;
00649     }
00650 //#pragma omp for schedule (dynamic, 8)
00651     for (ix = 0; ix < 9; ix++) {
00652       c_X_par_temp[ix].re = ((((increment[0].re * (real_T)g_b[ix] + increment[1]
00653         .re * (real_T)f_b[ix]) + increment[2].re * (real_T)e_b[ix]) + increment
00654         [3].re * (real_T)d_b[ix]) + increment[4].re * (real_T)c_b[ix]) +
00655         increment[5].re * (real_T)b_b[ix];
00656       c_X_par_temp[ix].im = ((((increment[0].im * (real_T)g_b[ix] + increment[1]
00657         .im * (real_T)f_b[ix]) + increment[2].im * (real_T)e_b[ix]) + increment
00658         [3].im * (real_T)d_b[ix]) + increment[4].im * (real_T)c_b[ix]) +
00659         increment[5].im * (real_T)b_b[ix];
00660     }
00661 
00662     expm(c_X_par_temp, LOGMX);
00663 //#pragma omp for schedule (dynamic, 8)
00664     for (ix = 0; ix < 6; ix++) {
00665       if (sigma_22_im == 0.0) {
00666         if (sigma_12[ix].im == 0.0) {
00667           sum_jacobian[ix].re = sigma_12[ix].re / sigma_22_re;
00668           sum_jacobian[ix].im = 0.0;
00669         } else if (sigma_12[ix].re == 0.0) {
00670           sum_jacobian[ix].re = 0.0;
00671           sum_jacobian[ix].im = sigma_12[ix].im / sigma_22_re;
00672         } else {
00673           sum_jacobian[ix].re = sigma_12[ix].re / sigma_22_re;
00674           sum_jacobian[ix].im = sigma_12[ix].im / sigma_22_re;
00675         }
00676       } else if (sigma_22_re == 0.0) {
00677         if (sigma_12[ix].re == 0.0) {
00678           sum_jacobian[ix].re = sigma_12[ix].im / sigma_22_im;
00679           sum_jacobian[ix].im = 0.0;
00680         } else if (sigma_12[ix].im == 0.0) {
00681           sum_jacobian[ix].re = 0.0;
00682           sum_jacobian[ix].im = -(sigma_12[ix].re / sigma_22_im);
00683         } else {
00684           sum_jacobian[ix].re = sigma_12[ix].im / sigma_22_im;
00685           sum_jacobian[ix].im = -(sigma_12[ix].re / sigma_22_im);
00686         }
00687       } else {
00688         brm = fabs(sigma_22_re);
00689         d = fabs(sigma_22_im);
00690         if (brm > d) {
00691           s = sigma_22_im / sigma_22_re;
00692           d = sigma_22_re + s * sigma_22_im;
00693           sum_jacobian[ix].re = (sigma_12[ix].re + s * sigma_12[ix].im) / d;
00694           sum_jacobian[ix].im = (sigma_12[ix].im - s * sigma_12[ix].re) / d;
00695         } else if (d == brm) {
00696           d = sigma_22_re > 0.0 ? 0.5 : -0.5;
00697           s = sigma_22_im > 0.0 ? 0.5 : -0.5;
00698           sum_jacobian[ix].re = (sigma_12[ix].re * d + sigma_12[ix].im * s) /
00699             brm;
00700           sum_jacobian[ix].im = (sigma_12[ix].im * d - sigma_12[ix].re * s) /
00701             brm;
00702         } else {
00703           s = sigma_22_re / sigma_22_im;
00704           d = sigma_22_im + s * sigma_22_re;
00705           sum_jacobian[ix].re = (s * sigma_12[ix].re + sigma_12[ix].im) / d;
00706           sum_jacobian[ix].im = (s * sigma_12[ix].im - sigma_12[ix].re) / d;
00707         }
00708       }
00709     }
00710 //#pragma omp for schedule (dynamic, 8)
00711     for (ix = 0; ix < 6; ix++) {
00712       for (i26 = 0; i26 < 6; i26++) {
00713         CH[i26 + 6 * ix] = dv13[i26 + 6 * ix] - (sum_jacobian[i26].re *
00714           sigma_12[ix].re - sum_jacobian[i26].im * -sigma_12[ix].im);
00715       }
00716     }
00717 
00718     chol(CH);
00719     randn(h_b);
00720 //#pragma omp for schedule (dynamic, 8)
00721     for (ix = 0; ix < 6; ix++) {
00722       random_coeff[ix] = 0.0;
00723       for (i26 = 0; i26 < 6; i26++) {
00724         random_coeff[ix] += CH[i26 + 6 * ix] * h_b[i26];
00725       }
00726     }
00727 //#pragma omp for schedule (dynamic, 8)
00728     for (ix = 0; ix < 9; ix++) {
00729       b_random_coeff[ix] = ((((random_coeff[0] * (real_T)g_b[ix] / 2.0 +
00730         random_coeff[1] * (real_T)f_b[ix]) + random_coeff[2] * (real_T)e_b[ix])
00731         + random_coeff[3] * (real_T)d_b[ix]) + random_coeff[4] * (real_T)c_b[ix])
00732         + random_coeff[5] * (real_T)b_b[ix];
00733     }
00734 
00735     b_expm(b_random_coeff, i_b);
00736 //#pragma omp for schedule (dynamic, 8)
00737     for (ix = 0; ix < 3; ix++) {
00738       for (i26 = 0; i26 < 3; i26++) {
00739         b_X_par_temp[ix + 3 * i26].re = 0.0;
00740         b_X_par_temp[ix + 3 * i26].im = 0.0;
00741         for (i = 0; i < 3; i++) {
00742           b_X_par_temp[ix + 3 * i26].re += X_par_temp[ix + 3 * i].re * LOGMX[i +
00743             3 * i26].re - X_par_temp[ix + 3 * i].im * LOGMX[i + 3 * i26].im;
00744           b_X_par_temp[ix + 3 * i26].im += X_par_temp[ix + 3 * i].re * LOGMX[i +
00745             3 * i26].im + X_par_temp[ix + 3 * i].im * LOGMX[i + 3 * i26].re;
00746         }
00747 
00748         c_X_par_temp[i26 + 3 * ix].re = i_b[i26 + 3 * ix];
00749         c_X_par_temp[i26 + 3 * ix].im = 0.0;
00750       }
00751     }
00752 //#pragma omp for schedule (dynamic, 8)
00753     for (ix = 0; ix < 3; ix++) {
00754       for (i26 = 0; i26 < 3; i26++) {
00755         d = 0.0;
00756         for (i = 0; i < 3; i++) {
00757           d += b_X_par_temp[ix + 3 * i].re * c_X_par_temp[i + 3 * i26].re -
00758             b_X_par_temp[ix + 3 * i].im * 0.0;
00759         }
00760 
00761         X_par_pred[((ix + 3 * i26) + 9 * par) + 225 * ((int32_T)t - 1)] = d;
00762       }
00763     }
00764 
00765     b_mldivide(*(real_T (*)[9])&X_par[9 * par + 225 * ((int32_T)(t - 1.0) - 1)],
00766                *(real_T (*)[9])&X_par_pred[9 * par + 225 * ((int32_T)t - 1)],
00767                b_random_coeff);
00768 //#pragma omp for schedule (dynamic, 8)
00769     for (ix = 0; ix < 3; ix++) {
00770       for (i26 = 0; i26 < 3; i26++) {
00771         AR_velocity[((i26 + 3 * ix) + 9 * par) + 225 * ((int32_T)t - 1)] =
00772           b_random_coeff[i26 + 3 * ix];
00773       }
00774     }
00775 
00776     b_center_x[0] = center_x;
00777     b_center_x[1] = center_y;
00778 //#pragma omp for schedule (dynamic, 8)
00779     for (ix = 0; ix < 2; ix++) {
00780       for (i26 = 0; i26 < 2; i26++) {
00781         Aff_matrix[i26 + 3 * ix] = X_par_pred[((i26 + 3 * ix) + 9 * par) + 225 *
00782           ((int32_T)t - 1)];
00783       }
00784     }
00785 //#pragma omp for schedule (dynamic, 8)
00786     for (ix = 0; ix < 2; ix++) {
00787       Aff_matrix[6 + ix] = X_par_pred[6 + ((ix + 9 * par) + 225 * ((int32_T)t -
00788         1))] + b_center_x[ix];
00789     }
00790 //#pragma omp for schedule (dynamic, 8)
00791     for (ix = 0; ix < 3; ix++) {
00792       Aff_matrix[2 + 3 * ix] = (real_T)iv10[ix];
00793     }
00794 
00795     b_image_warping(*(real_T (*)[336042])&ext_frame[0], Aff_matrix, point_matrix,
00796                     *(real_T (*)[1296])&warped_img[0]);
00797     b_image_warping(*(real_T (*)[336042])&ext_frame[336042], Aff_matrix,
00798                     point_matrix, *(real_T (*)[1296])&warped_img[1296]);
00799     b_image_warping(*(real_T (*)[336042])&ext_frame[672084], Aff_matrix,
00800                     point_matrix, *(real_T (*)[1296])&warped_img[2592]);
00801 
00802     /*             %% replace zeros with average values */
00803 //#pragma omp for schedule (dynamic, 8)
00804     for (ix = 0; ix < 1296; ix++) {
00805       b_zero_ind_z = (warped_img[2592 + ix] == 0.0);
00806       zero_ind_z[ix] = !b_zero_ind_z;
00807       c_zero_ind_z[ix] = b_zero_ind_z;
00808     }
00809 
00810     eml_li_find(c_zero_ind_z, tmp_data, tmp_size);
00811     eml_li_find(zero_ind_z, b_tmp_data, b_tmp_size);
00812     d_warped_img_size[0] = b_tmp_size[0];
00813     i = b_tmp_size[0] - 1;
00814 //#pragma omp for schedule (dynamic, 8)
00815     for (ix = 0; ix <= i; ix++) {
00816       warped_grad_x3[ix] = warped_img[b_tmp_data[ix] + 2591];
00817     }
00818 
00819     d = mean(warped_grad_x3, d_warped_img_size);
00820     i = tmp_size[0] - 1;
00821 //#pragma omp for schedule (dynamic, 8)
00822     for (ix = 0; ix <= i; ix++) {
00823       warped_img[tmp_data[ix] + 2591] = d;
00824     }
00825 
00826     eml_li_find(c_zero_ind_z, tmp_data, tmp_size);
00827     for (i = 0; i < 1296; i++) {
00828       zero_ind_z[i] = !c_zero_ind_z[i];
00829     }
00830 
00831     eml_li_find(zero_ind_z, b_tmp_data, b_tmp_size);
00832     e_warped_img_size[0] = b_tmp_size[0];
00833     i = b_tmp_size[0] - 1;
00834 //#pragma omp for schedule (dynamic, 8)
00835     for (ix = 0; ix <= i; ix++) {
00836       warped_grad_x3[ix] = warped_img[b_tmp_data[ix] - 1];
00837     }
00838 
00839     d = mean(warped_grad_x3, e_warped_img_size);
00840     i = tmp_size[0] - 1;
00841 //#pragma omp for schedule (dynamic, 8)
00842     for (ix = 0; ix <= i; ix++) {
00843       warped_img[tmp_data[ix] - 1] = d;
00844     }
00845 
00846     eml_li_find(c_zero_ind_z, tmp_data, tmp_size);
00847 //#pragma omp for schedule (dynamic, 8)
00848     for (i = 0; i < 1296; i++) {
00849       zero_ind_z[i] = !c_zero_ind_z[i];
00850     }
00851 
00852     eml_li_find(zero_ind_z, b_tmp_data, b_tmp_size);
00853     f_warped_img_size[0] = b_tmp_size[0];
00854     i = b_tmp_size[0] - 1;
00855 //#pragma omp for schedule (dynamic, 8)
00856     for (ix = 0; ix <= i; ix++) {
00857       warped_grad_x3[ix] = warped_img[b_tmp_data[ix] + 1295];
00858     }
00859 
00860     d = mean(warped_grad_x3, f_warped_img_size);
00861     i = tmp_size[0] - 1;
00862 //#pragma omp for schedule (dynamic, 8)
00863     for (ix = 0; ix <= i; ix++) {
00864       warped_img[tmp_data[ix] + 1295] = d;
00865     }
00866 
00867     /*             %% compute rigid transform */
00868     estimateRigidTransform(mean_img, warped_img, transform);
00869 //#pragma omp for schedule (dynamic, 8)
00870     for (ix = 0; ix < 4; ix++) {
00871       for (i26 = 0; i26 < 4; i26++) {
00872         rigid_transform_par[(i26 + (ix << 2)) + (par << 4)] = transform[i26 +
00873           (ix << 2)];
00874       }
00875     }
00876 //#pragma omp for schedule (dynamic, 8)
00877     for (ix = 0; ix < 1296; ix++) {
00878       for (i26 = 0; i26 < 3; i26++) {
00879         b_warped_img[i26 + (ix << 2)] = warped_img[ix + 1296 * i26];
00880       }
00881 
00882       b_warped_img[3 + (ix << 2)] = 1.0;
00883 //#pragma omp for schedule (dynamic, 8)
00884       for (i26 = 0; i26 < 4; i26++) {
00885         c_transform[ix + 1296 * i26] = 0.0;
00886         for (i = 0; i < 4; i++) {
00887           c_transform[ix + 1296 * i26] += transform[i26 + (i << 2)] *
00888             b_warped_img[i + (ix << 2)];
00889         }
00890       }
00891     }
00892 //#pragma omp for schedule (dynamic, 8)
00893     for (ix = 0; ix < 3; ix++) {
00894       memcpy(&warped_img_tr[1296 * ix], &c_transform[1296 * ix], 1296U * sizeof
00895              (real_T));
00896     }
00897 //#pragma omp for schedule (dynamic, 8)
00898     for (ix = 0; ix < 1296; ix++) {
00899       b_warped_img_tr[ix] = warped_img_tr[2592 + ix] - mean_img[2592 + ix];
00900     }
00901 //#pragma omp for schedule (dynamic, 8)
00902     for (ix = 0; ix < 1296; ix++) {
00903       b_warped_img_tr[ix + 1296] = warped_img_tr[1296 + ix] - mean_img[1296 + ix];
00904     }
00905 //#pragma omp for schedule (dynamic, 8)
00906     for (ix = 0; ix < 1296; ix++) {
00907       b_warped_img_tr[ix + 2592] = warped_img_tr[ix] - mean_img[ix];
00908     }
00909 
00910     d = b_norm(b_warped_img_tr) / 3.0;
00911 
00912     /*             %% */
00913     dist1Array[par] = d * d;
00914   }
00915 //#pragma omp for schedule (dynamic, 8)
00916   for (i = 0; i < 25; i++) {
00917     b_dist1Array[i] = (dist1Array[i] > 1000.0);
00918   }
00919 
00920   b_eml_li_find(b_dist1Array, c_tmp_data, tmp_size);
00921   i = tmp_size[0] - 1;
00922 //#pragma omp for schedule (dynamic, 8)
00923   for (ix = 0; ix <= i; ix++) {
00924     dist1Array[c_tmp_data[ix] - 1] = 1000.0;
00925   }
00926 //#pragma omp for schedule (dynamic, 8)
00927   for (ix = 0; ix < 25; ix++) {
00928     dist1Array[ix] *= -0.5;
00929   }
00930 
00931   b_exp(dist1Array);
00932 
00933   /* % Particle resampling */
00934   d = c_sum(dist1Array);
00935 //#pragma omp for schedule (dynamic, 8)
00936   for (ix = 0; ix < 25; ix++) {
00937     dist1Array[ix] /= d;
00938   }
00939 
00940   resampling(dist1Array, outindex);
00941 //#pragma omp for schedule (dynamic, 8)
00942   for (ix = 0; ix < 25; ix++) {
00943     for (i26 = 0; i26 < 3; i26++) {
00944       for (i = 0; i < 3; i++) {
00945         b_X_par_pred[(i + 3 * i26) + 9 * ix] = X_par_pred[((i + 3 * i26) + 9 *
00946           ((int32_T)outindex[ix] - 1)) + 225 * ((int32_T)t - 1)];
00947       }
00948     }
00949   }
00950 //#pragma omp for schedule (dynamic, 8)
00951   for (ix = 0; ix < 25; ix++) {
00952     for (i26 = 0; i26 < 3; i26++) {
00953       for (i = 0; i < 3; i++) {
00954         X_par[((i + 3 * i26) + 9 * ix) + 225 * ((int32_T)t - 1)] = b_X_par_pred
00955           [(i + 3 * i26) + 9 * ix];
00956       }
00957     }
00958   }
00959 //#pragma omp for schedule (dynamic, 8)
00960   for (ix = 0; ix < 25; ix++) {
00961     for (i26 = 0; i26 < 3; i26++) {
00962       for (i = 0; i < 3; i++) {
00963         b_X_par_pred[(i + 3 * i26) + 9 * ix] = AR_velocity[((i + 3 * i26) + 9 *
00964           ((int32_T)outindex[ix] - 1)) + 225 * ((int32_T)t - 1)];
00965       }
00966     }
00967   }
00968 //#pragma omp for schedule (dynamic, 8)
00969   for (ix = 0; ix < 25; ix++) {
00970     for (i26 = 0; i26 < 3; i26++) {
00971       for (i = 0; i < 3; i++) {
00972         AR_velocity[((i + 3 * i26) + 9 * ix) + 225 * ((int32_T)t - 1)] =
00973           b_X_par_pred[(i + 3 * i26) + 9 * ix];
00974       }
00975     }
00976   }
00977 //#pragma omp for schedule (dynamic, 8)
00978   for (ix = 0; ix < 25; ix++) {
00979     for (i26 = 0; i26 < 4; i26++) {
00980       for (i = 0; i < 4; i++) {
00981         b_rigid_transform_par[(i + (i26 << 2)) + (ix << 4)] =
00982           rigid_transform_par[(i + (i26 << 2)) + (((int32_T)outindex[ix] - 1) <<
00983           4)];
00984       }
00985     }
00986   }
00987 //#pragma omp for schedule (dynamic, 8)
00988   for (ix = 0; ix < 25; ix++) {
00989     for (i26 = 0; i26 < 4; i26++) {
00990       for (i = 0; i < 4; i++) {
00991         rigid_transform_par[(i + (i26 << 2)) + (ix << 4)] =
00992           b_rigid_transform_par[(i + (i26 << 2)) + (ix << 4)];
00993       }
00994     }
00995   }
00996 
00997   /* % Computing affine state particle mean  */
00998   i = 1;
00999   d = dist1Array[0];
01000   itmp = 0;
01001   if (rtIsNaN(dist1Array[0])) {
01002     ix = 2;
01003     exitg1 = FALSE;
01004     while ((exitg1 == 0U) && (ix < 26)) {
01005       i = ix;
01006       if (!rtIsNaN(dist1Array[ix - 1])) {
01007         d = dist1Array[ix - 1];
01008         exitg1 = TRUE;
01009       } else {
01010         ix++;
01011       }
01012     }
01013   }
01014 
01015   if (i < 25) {
01016     while (i + 1 < 26) {
01017       if (dist1Array[i] > d) {
01018         d = dist1Array[i];
01019         itmp = i;
01020       }
01021 
01022       i++;
01023     }
01024   }
01025 //#pragma omp for schedule (dynamic, 8)
01026   for (ix = 0; ix < 4; ix++) {
01027     mean_log[ix] = 0.0;
01028   }
01029 //#pragma omp for schedule (dynamic, 8)
01030   for (par = 0; par < 25; par++) {
01031     for (ix = 0; ix < 2; ix++) {
01032       for (i26 = 0; i26 < 2; i26++) {
01033         c_X_par_pred[i26 + (ix << 1)] = X_par_pred[((i26 + 3 * ix) + 9 * itmp) +
01034           225 * ((int32_T)t - 1)];
01035       }
01036     }
01037 //#pragma omp for schedule (dynamic, 8)
01038     for (ix = 0; ix < 2; ix++) {
01039       for (i26 = 0; i26 < 2; i26++) {
01040         b_X_par[i26 + (ix << 1)] = X_par[((i26 + 3 * ix) + 9 * par) + 225 *
01041           ((int32_T)t - 1)];
01042       }
01043     }
01044 
01045     c_mldivide(c_X_par_pred, b_X_par, b_LOGMX);
01046     b_eig(b_LOGMX, V, D);
01047     for (ix = 0; ix < 2; ix++) {
01048       dcv5[ix] = D[3 * ix];
01049     }
01050 
01051     c_log(dcv5);
01052     b_diag(dcv5, D);
01053 //#pragma omp for schedule (dynamic, 8)
01054     for (ix = 0; ix < 2; ix++) {
01055       for (i26 = 0; i26 < 2; i26++) {
01056         b_V[ix + (i26 << 1)].re = 0.0;
01057         b_V[ix + (i26 << 1)].im = 0.0;
01058         for (i = 0; i < 2; i++) {
01059           b_V[ix + (i26 << 1)].re += V[ix + (i << 1)].re * D[i + (i26 << 1)].re
01060             - V[ix + (i << 1)].im * D[i + (i26 << 1)].im;
01061           b_V[ix + (i26 << 1)].im += V[ix + (i << 1)].re * D[i + (i26 << 1)].im
01062             + V[ix + (i << 1)].im * D[i + (i26 << 1)].re;
01063         }
01064       }
01065     }
01066 
01067     b_mrdivide(b_V, V, D);
01068 //#pragma omp for schedule (dynamic, 8)
01069     for (ix = 0; ix < 4; ix++) {
01070       mean_log[ix] += D[ix].re / 25.0;
01071     }
01072   }
01073 
01074   c_expm(mean_log, b_LOGMX);
01075 //#pragma omp for schedule (dynamic, 8)
01076   for (ix = 0; ix < 25; ix++) {
01077     for (i26 = 0; i26 < 2; i26++) {
01078       c_X_par[i26 + (ix << 1)] = X_par[6 + ((i26 + 9 * ix) + 225 * ((int32_T)t -
01079         1))];
01080     }
01081   }
01082 
01083   b_mean(c_X_par, mean_trans);
01084 
01085   /*  mean_X_par(:,:,t) = [mean_gl mean_trans;0 0 1]; */
01086   /* % Tracked object image update */
01087   b_center_x[0] = center_x;
01088   b_center_x[1] = center_y;
01089 //#pragma omp for schedule (dynamic, 8)
01090   for (ix = 0; ix < 2; ix++) {
01091     for (i26 = 0; i26 < 2; i26++) {
01092       c_X_par_pred[ix + (i26 << 1)] = 0.0;
01093       for (i = 0; i < 2; i++) {
01094         c_X_par_pred[ix + (i26 << 1)] += X_par_pred[((ix + 3 * i) + 9 * itmp) +
01095           225 * ((int32_T)t - 1)] * b_LOGMX[i + (i26 << 1)];
01096       }
01097     }
01098   }
01099 //#pragma omp for schedule (dynamic, 8)
01100   for (ix = 0; ix < 2; ix++) {
01101     for (i26 = 0; i26 < 2; i26++) {
01102       Aff_matrix[i26 + 3 * ix] = c_X_par_pred[i26 + (ix << 1)];
01103     }
01104   }
01105 //#pragma omp for schedule (dynamic, 8)
01106   for (ix = 0; ix < 2; ix++) {
01107     Aff_matrix[6 + ix] = mean_trans[ix] + b_center_x[ix];
01108   }
01109 //#pragma omp for schedule (dynamic, 8)
01110   for (ix = 0; ix < 3; ix++) {
01111     Aff_matrix[2 + 3 * ix] = (real_T)iv10[ix];
01112   }
01113 
01114   /*  %% apply rigid transform to the tracked image and replace zeros with average values */
01115   memset(&warped_img[0], 0, 3888U * sizeof(real_T));
01116   b_image_warping(*(real_T (*)[336042])&ext_frame[0], Aff_matrix, point_matrix, *
01117                   (real_T (*)[1296])&warped_img[0]);
01118   b_image_warping(*(real_T (*)[336042])&ext_frame[336042], Aff_matrix,
01119                   point_matrix, *(real_T (*)[1296])&warped_img[1296]);
01120   b_image_warping(*(real_T (*)[336042])&ext_frame[672084], Aff_matrix,
01121                   point_matrix, *(real_T (*)[1296])&warped_img[2592]);
01122 //#pragma omp for schedule (dynamic, 8)
01123   for (ix = 0; ix < 1296; ix++) {
01124     b_zero_ind_z = (warped_img[2592 + ix] == 0.0);
01125     zero_ind_z[ix] = !b_zero_ind_z;
01126     c_zero_ind_z[ix] = b_zero_ind_z;
01127   }
01128 
01129   eml_li_find(c_zero_ind_z, tmp_data, tmp_size);
01130   eml_li_find(zero_ind_z, b_tmp_data, b_tmp_size);
01131   g_warped_img_size[0] = b_tmp_size[0];
01132   i = b_tmp_size[0] - 1;
01133 //#pragma omp for schedule (dynamic, 8)
01134   for (ix = 0; ix <= i; ix++) {
01135     warped_grad_x3[ix] = warped_img[b_tmp_data[ix] + 2591];
01136   }
01137 
01138   d = mean(warped_grad_x3, g_warped_img_size);
01139   i = tmp_size[0] - 1;
01140 //#pragma omp for schedule (dynamic, 8)
01141   for (ix = 0; ix <= i; ix++) {
01142     warped_img[tmp_data[ix] + 2591] = d;
01143   }
01144 
01145   eml_li_find(c_zero_ind_z, tmp_data, tmp_size);
01146 //#pragma omp for schedule (dynamic, 8)
01147   for (i = 0; i < 1296; i++) {
01148     zero_ind_z[i] = !c_zero_ind_z[i];
01149   }
01150 
01151   eml_li_find(zero_ind_z, b_tmp_data, b_tmp_size);
01152   h_warped_img_size[0] = b_tmp_size[0];
01153   i = b_tmp_size[0] - 1;
01154 //#pragma omp for schedule (dynamic, 8)
01155   for (ix = 0; ix <= i; ix++) {
01156     warped_grad_x3[ix] = warped_img[b_tmp_data[ix] - 1];
01157   }
01158 
01159   d = mean(warped_grad_x3, h_warped_img_size);
01160   i = tmp_size[0] - 1;
01161 //#pragma omp for schedule (dynamic, 8)
01162   for (ix = 0; ix <= i; ix++) {
01163     warped_img[tmp_data[ix] - 1] = d;
01164   }
01165 
01166   eml_li_find(c_zero_ind_z, tmp_data, tmp_size);
01167 //#pragma omp for schedule (dynamic, 8)
01168   for (i = 0; i < 1296; i++) {
01169     zero_ind_z[i] = !c_zero_ind_z[i];
01170   }
01171 
01172   eml_li_find(zero_ind_z, b_tmp_data, b_tmp_size);
01173   i_warped_img_size[0] = b_tmp_size[0];
01174   i = b_tmp_size[0] - 1;
01175 //#pragma omp for schedule (dynamic, 8)
01176   for (ix = 0; ix <= i; ix++) {
01177     warped_grad_x3[ix] = warped_img[b_tmp_data[ix] + 1295];
01178   }
01179 
01180   d = mean(warped_grad_x3, i_warped_img_size);
01181   i = tmp_size[0] - 1;
01182 //#pragma omp for schedule (dynamic, 8)
01183   for (ix = 0; ix <= i; ix++) {
01184     warped_img[tmp_data[ix] + 1295] = d;
01185   }
01186 //#pragma omp for schedule (dynamic, 8)
01187   for (ix = 0; ix < 1296; ix++) {
01188     for (i26 = 0; i26 < 3; i26++) {
01189       b_warped_img[i26 + (ix << 2)] = warped_img[ix + 1296 * i26];
01190     }
01191 
01192     b_warped_img[3 + (ix << 2)] = 1.0;
01193 //#pragma omp for schedule (dynamic, 8)
01194     for (i26 = 0; i26 < 4; i26++) {
01195       c_rigid_transform_par[ix + 1296 * i26] = 0.0;
01196       for (i = 0; i < 4; i++) {
01197         c_rigid_transform_par[ix + 1296 * i26] += rigid_transform_par[(i26 + (i <<
01198           2)) + (itmp << 4)] * b_warped_img[i + (ix << 2)];
01199       }
01200     }
01201   }
01202 //#pragma omp for schedule (dynamic, 8)
01203   for (ix = 0; ix < 3; ix++) {
01204     memcpy(&warped_img_tr[1296 * ix], &c_rigid_transform_par[1296 * ix], 1296U *
01205            sizeof(real_T));
01206   }
01207 //#pragma omp for schedule (dynamic, 8)
01208   for (ix = 0; ix < 1296; ix++) {
01209     tracked_images[ix + 1296 * ((int32_T)t - 1)] = warped_img_tr[ix];
01210   }
01211 //#pragma omp for schedule (dynamic, 8)
01212   for (ix = 0; ix < 1296; ix++) {
01213     tracked_images[12960000 + (ix + 1296 * ((int32_T)t - 1))] = warped_img_tr
01214       [1296 + ix];
01215   }
01216 //#pragma omp for schedule (dynamic, 8)
01217   for (ix = 0; ix < 1296; ix++) {
01218     tracked_images[25920000 + (ix + 1296 * ((int32_T)t - 1))] = warped_img_tr
01219       [2592 + ix];
01220   }
01221 
01222   c_mean(warped_img, centroid);
01223   emxInit_real_T(&b_tracked_images, 2);
01224   emxInit_real_T(&c_tracked_images, 2);
01225   emxInit_real_T(&d_tracked_images, 2);
01226   if ((t >= 50.0) && (rt_remd_snf(t, 50.0) == 0.0)) {
01227     ix = d_tracked_images->size[0] * d_tracked_images->size[1];
01228     d_tracked_images->size[0] = 1296;
01229     d_tracked_images->size[1] = (int32_T)t;
01230     emxEnsureCapacity((emxArray__common *)d_tracked_images, ix, (int32_T)sizeof
01231                       (real_T));
01232     i = (int32_T)t - 1;
01233 //#pragma omp for schedule (dynamic, 8)
01234     for (ix = 0; ix <= i; ix++) {
01235       for (i26 = 0; i26 < 1296; i26++) {
01236         d_tracked_images->data[i26 + d_tracked_images->size[0] * ix] =
01237           tracked_images[i26 + 1296 * ix];
01238       }
01239     }
01240 
01241     d_mean(d_tracked_images, warped_grad_x3);
01242 //#pragma omp for schedule (dynamic, 8)
01243     for (ix = 0; ix < 1296; ix++) {
01244       mean_img[ix] = warped_grad_x3[ix];
01245     }
01246 
01247     ix = c_tracked_images->size[0] * c_tracked_images->size[1];
01248     c_tracked_images->size[0] = 1296;
01249     c_tracked_images->size[1] = (int32_T)t;
01250     emxEnsureCapacity((emxArray__common *)c_tracked_images, ix, (int32_T)sizeof
01251                       (real_T));
01252     i = (int32_T)t - 1;
01253 //#pragma omp for schedule (dynamic, 8)
01254     for (ix = 0; ix <= i; ix++) {
01255       for (i26 = 0; i26 < 1296; i26++) {
01256         c_tracked_images->data[i26 + c_tracked_images->size[0] * ix] =
01257           tracked_images[12960000 + (i26 + 1296 * ix)];
01258       }
01259     }
01260 
01261     d_mean(c_tracked_images, warped_grad_x3);
01262 //#pragma omp for schedule (dynamic, 8)
01263     for (ix = 0; ix < 1296; ix++) {
01264       mean_img[1296 + ix] = warped_grad_x3[ix];
01265     }
01266 
01267     ix = b_tracked_images->size[0] * b_tracked_images->size[1];
01268     b_tracked_images->size[0] = 1296;
01269     b_tracked_images->size[1] = (int32_T)t;
01270     emxEnsureCapacity((emxArray__common *)b_tracked_images, ix, (int32_T)sizeof
01271                       (real_T));
01272     i = (int32_T)t - 1;
01273 //#pragma omp for schedule (dynamic, 8)
01274     for (ix = 0; ix <= i; ix++) {
01275       for (i26 = 0; i26 < 1296; i26++) {
01276         b_tracked_images->data[i26 + b_tracked_images->size[0] * ix] =
01277           tracked_images[25920000 + (i26 + 1296 * ix)];
01278       }
01279     }
01280 
01281     d_mean(b_tracked_images, warped_grad_x3);
01282 //#pragma omp for schedule (dynamic, 8)
01283     for (ix = 0; ix < 1296; ix++) {
01284       mean_img[2592 + ix] = warped_grad_x3[ix];
01285     }
01286 
01287     /*         %% replace non connected values with mean values in the mean img */
01288     removeOutliers(mean_img);
01289   }
01290 
01291   emxFree_real_T(&d_tracked_images);
01292   emxFree_real_T(&c_tracked_images);
01293   emxFree_real_T(&b_tracked_images);
01294 }
01295 
01296 void eml_li_find(const boolean_T x[1296], int32_T y_data[1296], int32_T y_size[1])
01297 {
01298   int32_T j;
01299   int32_T i;
01300   y_size[0] = compute_nones(x);
01301   j = 0;
01302   for (i = 0; i < 1296; i++) {
01303     if (x[i]) {
01304       y_data[j] = i + 1;
01305       j++;
01306     }
01307   }
01308 }
01309 
01310 /* End of code generation (compute_prob1.cpp) */


depth_tracker_ros_vr8
Author(s): shusain
autogenerated on Fri Dec 6 2013 20:45:46