00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00032 #include <mtt/mtt_auxiliar.h>
00033
00034 void init_config(t_config*config)
00035 {
00036 config->maxr=50.;
00037
00038 config->in_clip=0.1;
00039 config->out_clip=config->maxr;
00040
00041 config->in_angle= 0;
00042 config->out_angle= 2*M_PI;
00043
00044
00045
00046 config->cluster_break_distance=10.;
00047
00048
00049
00050
00051 config->fi=5.0*(M_PI/180.);
00052
00053 config->beta=60*(M_PI/180.);
00054
00055
00056 config->C0=0.2;
00057
00058 config->filter_max_variation=0.001;
00059
00060
00061 config->excluding_dr=250;
00062
00063 config->point_occlusion_distance=500.;
00064
00065
00066
00067 config->max_line_per_object=1000;
00068 config->max_mean_variance=0.1;
00069
00070
00071 config->data_acc_scans=20;
00072
00073
00074 config->max_missing_iterations=30;
00075
00076
00077 config->overlap_max=5;
00078 config->overlap_distance=0.2;
00079
00080 config->display_min_lifetime=10;
00081
00082
00083 config->dt=1./30.;
00084
00085
00086
00087
00088 config->estimation_window_size=2;
00089
00090 config->max_stationary_velocity=0.030;
00091 config->min_moving_velocity=0.100;
00092
00093 config->velocity_acc_size=10;
00094
00095 config->path_lenght=1000;
00096
00097
00098
00099
00100
00101 config->default_ellipse_axis=0.500;
00102 config->max_ellipse_axis=1.500;
00103 config->min_ellipse_axis=0.050;
00104
00105 config->ezA=1.0;
00106 config->ezB=0.5;
00107 }
00108
00109 void init_flags(t_flag*flags)
00110 {
00111 flags->fp_s=true;
00112 flags->fi=true;
00113 }
00114
00115 double get_fps(double dt,t_fps*acc)
00116 {
00117 static bool initialise=true;
00118 static unsigned int max_size=30;
00119
00120 if(initialise)
00121 {
00122 memset(acc->fps,0,max_size*sizeof(double));
00123 acc->position=0;
00124 acc->current_size=0;
00125
00126 initialise=false;
00127 }
00128
00129 acc->fps[acc->position]=1./(double)dt;
00130 acc->position++;
00131
00132 if(acc->current_size<max_size)
00133 acc->current_size++;
00134
00135 if(acc->position==max_size)
00136 acc->position=0;
00137
00138 double mean_fps=0;
00139
00140 for(unsigned int i=0;i<acc->current_size;i++)
00141 mean_fps+=acc->fps[i];
00142
00143 mean_fps/=acc->current_size;
00144
00145 return mean_fps;
00146 }
00147
00148 int my_tictoc(int status)
00149 {
00150 static struct timeval timestart;
00151 struct timeval timenow;
00152
00153 if(status==TIC)
00154 {
00155 gettimeofday(×tart,NULL);
00156 return 0;
00157 }else if (status==TOC)
00158 {
00159 gettimeofday(&timenow,NULL);
00160 int ret=timediff(timenow,timestart);
00161 return ret;
00162 }else
00163 return -1;
00164 }
00165
00166 int timediff(struct timeval t1,struct timeval t2)
00167 {
00168 return (t1.tv_sec-t2.tv_sec)*1000000+(t1.tv_usec-t2.tv_usec);
00169 }
00170
00171 double point2point_distance(double xi,double yi,double xf,double yf)
00172 { return sqrt((xi-xf)*(xi-xf)+(yi-yf)*(yi-yf));}
00173
00174 double point2point_algebric_distance(double xi,double yi,double xf,double yf)
00175 { return (xi-xf)*(xi-xf)+(yi-yf)*(yi-yf);}
00176
00177 double point2line_distance(double alpha,double ro,double x,double y)
00178 { return ro-x*cos(alpha)-y*sin(alpha);}