00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __TLVISION_H__
00018 #define __TLVISION_H__
00019
00020
00021
00022 #if _MSC_VER >= 1400
00023 #define POINTER_64 __ptr64
00024 #endif
00025
00026
00027
00028 #include <iostream>
00029 #include <stdio.h>
00030 #include <malloc.h>
00031 #define _USE_MATH_DEFINES
00032 #include <math.h>
00033
00034 using std::cout;
00035 using std::endl;
00036
00037
00038 #ifndef M_PI
00039 #define TL_PI 3.14159265358979323846
00040 #else
00041 #define TL_PI M_PI
00042 #endif
00043
00044
00045
00046 #define TL_DEFAULT_COLS 320
00047 #define TL_DEFAULT_ROWS 240
00048 #define TL_MAX_PIXEL_VAL 255
00049 #define TL_MIN_PIXEL_VAL 0
00050 #define TL_MAX_HPIXEL_VAL 65535
00051
00052
00053
00054 #define TL_NOT_CONNEX 0
00055 #define TL_CONNEX_4 1
00056 #define TL_CONNEX_8 2
00057
00058
00059
00060
00061
00062
00063
00064 typedef unsigned char tlPixel;
00065 typedef short tlHRPixel;
00066
00067 typedef int tlHistData;
00068 #define TL_PIXEL(row,col,width) (((row)*(width))+(col))
00069 #define TL_MIN(a,b) (((a)<(b))?(a):(b))
00070 #define TL_MAX(a,b) (((a)>(b))?(a):(b))
00071 #define TL_BOUND(a,x,b) (TL_MIN(TL_MAX((a),(x)),(b)))
00072
00073
00074
00075
00076
00077
00078 #define TL_HMHL_TO_HVAL(hm, hl) (((hm) << 8) | (hl))
00079
00080
00081 #define TL_HVAL_TO_HM(hval) ((hval) >> 8)
00082 #define TL_HVAL_TO_HL(hval) ((hval & 0xff))
00083
00084
00085 #define TL_DEG_TO_HVAL(deg) (unsigned short int) (TL_MAX_HPIXEL_VAL*(deg)/360)
00086 #define TL_HVAL_TO_DEG(hval) (360.0f*(hval)/TL_MAX_HPIXEL_VAL) // float
00087
00088
00089 #define TL_PCT_TO_SVAL(pct) (tlPixel) (TL_MAX_PIXEL_VAL*(pct)/100)
00090 #define TL_SVAL_TO_PCT(sval) (100.0f*(sval)/TL_MAX_PIXEL_VAL) // float
00091
00092
00093 #define TL_PCT_TO_IVAL(pct) (tlPixel) (TL_MAX_PIXEL_VAL*(pct)/100)
00094 #define TL_IVAL_TO_PCT(ival) (100.0f*(ival)/TL_MAX_PIXEL_VAL) // float
00095
00096
00097 #define TL_PAUSE getc();
00098
00099 #define TL_NOT_IMPLEMENTED { \
00100 printf ("TL lib error: call to an unimplemented routine\n"); \
00101 return TL_ERROR_NOT_IMPLEMENTED; \
00102 }
00103
00104
00105 class tlSize;
00106 class tlLocation;
00107 class tlRect;
00108 class tlPixelArray;
00109 class tlBackground;
00110 class tlBlobs;
00111 class tlHough;
00112 class tlChain;
00113 class tlColor;
00114 class tlColorModel;
00115 template <typename T> class tlConst;
00116 class tlHist;
00117 class tlHist2D;
00118 class tlImage;
00119 class tlLine;
00120 class tlMask;
00121 class tlObject;
00122 class tlPoint;
00123 class tlSpiral;
00124
00125
00126
00127 extern int tlVerbose;
00128 void tl_set_verbose (int val);
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138 enum tl_format { RGB, NRG, HSI, YUV, GRAY, BIN, STEREO, CUSTOM };
00139
00140
00141 #define TL_RGB_WIDTH 3
00142 #define TL_NRG_WIDTH 2
00143 #define TL_HSI_WIDTH 4
00144 #define TL_YUV_WIDTH 3
00145 #define TL_GRAY_WIDTH 1
00146 #define TL_BIN_WIDTH 1
00147 #define TL_STEREO_WIDTH 1
00148
00149
00150 #define TL_MAX_PIXEL_WIDTH 4
00151
00152
00153 inline int tl_pixel_width (tl_format format)
00154 {
00155 switch(format){
00156 case RGB: return TL_RGB_WIDTH;
00157 case YUV: return TL_YUV_WIDTH;
00158 case NRG: return TL_NRG_WIDTH;
00159 case HSI: return TL_HSI_WIDTH;
00160 case GRAY: return TL_GRAY_WIDTH;
00161 case BIN: return TL_BIN_WIDTH;
00162 case STEREO: return TL_STEREO_WIDTH;
00163 default:
00164 return 0;
00165 }
00166 }
00167
00168
00169
00170 #define TL_CHANNEL_RED 0
00171 #define TL_CHANNEL_GREEN 1
00172 #define TL_CHANNEL_BLUE 2
00173 #define TL_CHANNEL_H 0
00174 #define TL_CHANNEL_HM 0
00175 #define TL_CHANNEL_HL 1
00176 #define TL_CHANNEL_S 2
00177 #define TL_CHANNEL_I 3
00178 #define TL_CHANNEL_NR 0
00179 #define TL_CHANNEL_NG 1
00180 #define TL_CHANNEL_GRAY 0
00181 #define TL_CHANNEL_BIN 0
00182 #define TL_CHANNEL_STEREO 0
00183
00184
00185
00186
00187
00188
00189
00190
00191 #include "tlChannel.h"
00192 #include "tlConvolution.h"
00193 #include "tlEdges.h"
00194 #include "tlError.h"
00195 #include "tlExtract.h"
00196 #include "tlFile.h"
00197 #include "tlFilter.h"
00198 #include "tlFind.h"
00199 #include "tlFormatConversion.h"
00200 #include "tlMemory.h"
00201 #include "tlMorph.h"
00202 #include "tlNormalize.h"
00203 #include "tlPixel.h"
00204 #include "tlScale.h"
00205 #include "tlThread.h"
00206 #include "tlTimer.h"
00207 #include "tlTransforms.h"
00208
00209
00210 #ifndef _TLIB_BUILD_
00211
00212
00213 #include "tlSize.h"
00214 #include "tlLocation.h"
00215 #include "tlRect.h"
00216 #include "tlPixelArray.h"
00217 #include "tlBackground.h"
00218 #include "tlBlobs.h"
00219 #include "tlChain.h"
00220 #include "tlColor.h"
00221 #include "tlColorModel.h"
00222 #include "tlConst.h"
00223 #include "tlHist.h"
00224 #include "tlHist2D.h"
00225 #include "tlHough.h"
00226 #include "tlImage.h"
00227 #include "tlLine.h"
00228 #include "tlMask.h"
00229 #include "tlObject.h"
00230 #include "tlPoint.h"
00231 #include "tlSpiral.h"
00232
00233 #endif
00234
00235
00236
00237
00238
00239
00240
00241
00242 extern char *tl_app_name;
00243 int tl_init_lib ();
00244 int tl_init_lib (int argc, char **argv);
00245
00246
00247 #endif
00248