00001
00002
00003
00004
00005
00006
00007
00019 #ifdef __cplusplus
00020 extern "C" {
00021 #endif
00022
00023 #ifndef _SMT_H_
00024 #define _SMT_H_
00025
00026 #ifdef WIN32
00027
00028 #include <stdio.h>
00029 #include <tchar.h>
00030
00031 #include <windows.h>
00032
00033 #endif
00034
00035 #include <stdio.h>
00036 #include <string.h>
00037 #include <assert.h>
00038 #include <math.h>
00039
00040
00041
00042 #define DEFAULT_NCOL_SENSOR 640 // Sensor size
00043 #define DEFAULT_NROW_SENSOR 480
00044
00045
00046 #define DEFAULT_NCOL_PROC 320//16//128 Size of multi-touch data processing
00047 #define DEFAULT_NROW_PROC 240//16//96
00048
00049
00050 #define MAX_COORD 100 //! Determine range of resultant xy touch position (0~MAX_COORD)
00051 #define MAXCOL 640 //! Sensor & data processing size
00052 #define MAXROW 480
00053 #define MAXFILTERSIZE 10 // Size of spatial filters
00054 #define MAXTOUCH 100
00055 #define MAX_EVENT 100
00056
00057
00058 extern int mt_do_smoothing;
00059 extern int mt_do_highpass;
00060 extern int mt_do_smoothing2;
00061
00062
00063 extern int mt_ncol_sensor;
00064 extern int mt_nrow_sensor;
00065 extern int mt_ncol_proc;
00066 extern int mt_nrow_proc;
00067
00068
00069 extern int mt_sensor_data[MAXCOL*MAXROW];
00070 extern int mt_sensor_data_temp[MAXCOL*MAXROW];
00071 extern int mt_resized[MAXCOL*MAXROW];
00072 extern int mt_offset[MAXCOL*MAXROW];
00073 extern int mt_diff[MAXCOL*MAXROW];
00074 extern int mt_smoothing[MAXCOL*MAXROW];
00075 extern int mt_highpass[MAXCOL*MAXROW];
00076 extern int mt_highpass_smoothing[MAXCOL*MAXROW];
00077 extern float mt_amplification[MAXCOL*MAXROW];
00078 extern int mt_BW[MAXCOL*MAXROW];
00079 extern int mt_LABEL[MAXCOL*MAXROW];
00080
00081
00082 extern int mt_nevent;
00083 extern int mt_noldevent;
00084 extern int mt_ntouch;
00085 extern int mt_nlabel;
00086 extern int mt_noldtouch;
00087
00088
00089 extern int mt_masksize;
00090 extern int mt_masksize1;
00091 extern float mt_min_amplification_range;
00092 extern float mt_max_amplification_range;
00093 extern int mt_npower;
00094
00095 extern int mt_max_sensor;
00096
00097 extern int mt_bwthreshold1;
00098 extern int mt_bwthreshold2;
00099
00100
00101 extern int mt_th_min_area, mt_th_max_area;
00102 extern float mt_th_dist2;
00103
00104 extern int mt_nevent;
00105 extern int mt_angle;
00106 extern float mt_scale;
00107 extern int mt_oldangle;
00108 extern float mt_oldscale;
00109
00110 extern float mt_xmin_n, mt_xmax_n, mt_ymin_n, mt_ymax_n;
00111
00112 extern int mt_id_ex;
00113
00114 #ifdef WIN32
00115 extern float mt_time_resize;
00116 extern float mt_time_diff;
00117 extern float mt_time_smoothing;
00118 extern float mt_time_highpass;
00119 extern float mt_time_smoothing2;
00120 extern float mt_time_amplificadtion;
00121 extern float mt_time_bw;
00122 extern float mt_time_labeling;
00123 extern float mt_time_runsmt;
00124 #endif
00125
00126 typedef struct tagTOUCHBLOB {
00127 int id;
00128 int id_ex;
00129 int raw_area;
00130 float area;
00131 float x;
00132 float y;
00133 float raw_x;
00134 float raw_y;
00135 float dist2;
00136 int flag_move;
00137 int sum_signal;
00138 float pressure;
00139 } TOUCHBLOB;
00140
00141
00142 typedef struct tagTOUCHEVENT {
00143 int event;
00144 float x;
00145 float y;
00146 float dx;
00147 float dy;
00148 int num_touch;
00149 int info;
00150
00151 TOUCHBLOB touch[1];
00152 } TOUCHEVENT;
00153
00154 TOUCHBLOB BLOBS[MAXTOUCH], TOUCH[MAXTOUCH], OLD_TOUCH[MAXTOUCH];
00155 TOUCHEVENT EVENTLIST[MAX_EVENT];
00156 TOUCHEVENT EVENTLIST_OLD[MAX_EVENT];
00157
00158
00159 #define SWIPE_LEFT 1
00160 #define SWIPE_RIGHT 2
00161 #define SWIPE_UP 3
00162 #define SWIPE_DOWN 4
00163 typedef enum
00164 {
00165 E_NOEVENT,
00166 E_FINGER_DOWN,
00167 E_FINGER_UP,
00168 E_FINGER_MOVE,
00169 E_FINGER_DRAG,
00170 E_TOUCH_START,
00171 E_TAP,
00172 E_RIGHT_TAP,
00173 E_DOUBLE_TAP,
00174 E_FINGER_HOLD,
00175 E_TOUCH_END,
00176 E_ROTATE,
00177 E_SCALE,
00178 E_FLICK,
00179 E_NFINGER_MOVE,
00180 E_NFINGER_SWIPE,
00181 E_NFINGER_TAP
00182 } TOUCH_EVENTS;
00183
00184
00185 typedef enum
00186 {
00187 TSTATE_IDLE,
00188 TSTATE_DOUBLE_TAP,
00189 TSTATE_UP,
00190 TSTATE_INITPRESS,
00191 TSTATE_MULTITOUCH,
00192 TSTATE_DOWN,
00193 TSTATE_DRAG,
00194 TSTATE_HOLD
00195 } TOUCH_STATES;
00196
00197
00198
00199
00200
00201
00202 extern float mt_calibration_params[6];
00203
00204
00205
00206
00207
00208 void initsmt(void);
00209 void setoffset(void);
00210 void runsmt(void);
00211 void preprocessing(void);
00212 void cclabel(void);
00213 void blobprops(void);
00214 void identtouch(void);
00215 void tracktouch(void);
00216 void gonext(void);
00217 void runsmtwin32(int *x, int *y, int ntouch);
00218
00219
00220 void gesture_recognition(void);
00221 int flick(void);
00222 int rotate(void);
00223 int scale(void);
00224 void state_machine(void);
00225 void initeventlist(void);
00226 void notifyevent(int eventid, TOUCHBLOB * touch, TOUCHEVENT * tevent, int event_index, float x, float y , float dx, float dy, int num_touch, int info);
00227
00228
00229 void initblob(TOUCHBLOB * b);
00230 void copyblob(TOUCHBLOB * src, TOUCHBLOB * dest);
00231 void addtouch(int x, int y);
00232 void event_to_string(char * s, int e);
00233 void savesnapshot(void);
00234 void copyeventlist(TOUCHEVENT * src, TOUCHEVENT * dst, int n);
00235 void computecaliparams(float * x, float * y, float * xd, float * yd, float * cali);
00236 float computecalipos(float x, float y, float a, float b, float c);
00237
00238
00239 float linearscale(float x, float min_x, float max_x, float min_y, float max_y);
00240 int iminarray(int * x, int n);
00241 int imaxarray(int * x, int n);
00242 float fminarray(float * x, int n);
00243 float fmaxarray(float * y, int n);
00244 float favgarray(int * x, int n);
00245 int computedist2(int x1, int y1, int x2, int y2);
00246 void meanfilter(int * Iy, int * Ix, int numrow, int numcol, int n);
00247 void meanfilter_threshold(int * Iy, int * Ix, int numrow, int numcol, int n, int apply_filter_threshold);
00248 unsigned int uimin(unsigned int x, unsigned int y);
00249 unsigned int uimax(unsigned int x, unsigned int y);
00250 void imresizenearest(int * x, int nrowx, int ncolx, int * y, int nrowy, int ncoly);
00251 void imresizebilinear(int * x, int nrowx, int ncolx, int * y, int nrowy, int ncoly);
00252 void imresizebicubic(int * x, int nrowx, int ncolx, int * y, int nrowy, int ncoly);
00253 float interpcc(float v1, float v2, float v3, float v4, float d);
00254 int ilimit(int x, int l, int u);
00255 float flimit(float x, float l, float u);
00256 float ucmse(unsigned char * x, unsigned char * y, int n);
00257 float fpower(float a, int b);
00258 void icopyarray(int * src, int * dst, int nlength);
00259 void savearray(FILE * fp, const char * filename, int *x, int n);
00260 unsigned char ucminarray(unsigned char * x, int n);
00261 signed char scminarray(signed char * x, int n);
00262 unsigned char ucmaxarray(unsigned char * y, int n);
00263 void cwise2rwise(int* src, int* dst, int row, int col);
00264 void rwise2cwise(int* src, int* dst, int row, int col);
00265 void backgroundfiltering(unsigned char* src, unsigned char *dst, int row, int col);
00266
00267 #endif
00268
00269 #ifdef __cplusplus
00270 }
00271 #endif