camellia.h

Go to the documentation of this file.
00001 
00051 #ifndef _CAMELLIA_H_
00052 #define _CAMELLIA_H_
00053 
00054 #define CAM_VERSION "2.7.0 : Bastille ($Rev: 270 $)"
00055 
00056 #include <stdlib.h>
00057 
00058 /*******************************************
00059  * Compilation options :                   *
00060  */
00061 // Pixel definition
00062 #define CAM_PIXEL unsigned char
00063 #define CAM_SIGNED_PIXEL signed char
00064 
00065 // Max image size
00066 #define CAM_MAX_SCANLINE 1280
00067 #define CAM_MAX_FRAME_HEIGHT 1024
00068 
00069 // 64-bit processor or memory bandwidth?
00070 #define CAM_64BITS
00071 
00072 // Pentium4 optimizations?
00073 #define CAM_OPT_P4
00074 
00075 // Big endian architecture?
00076 //#define CAM_BIG_ENDIAN
00077 
00078 // Generate 8 AND 16 bits pixel size code
00079 #define CAM_GENERATE_FULL_CODE
00080 
00081 /*                                         *
00082  *******************************************/ 
00083 #ifdef _WIN32
00084 #define CAM_INT64 __int64
00085 #define CAM_UINT64 unsigned __int64
00086 #else
00087 #define CAM_INT64 long long
00088 #define CAM_UINT64 unsigned long long
00089 #endif
00090 
00091 #ifdef __INTEL_COMPILER
00092 #define CAM_ALIGN16 __declspec(align(16))
00093 #else
00094 #define CAM_ALIGN16
00095 #endif
00096 
00097 #define CAM_FIXED_POINT signed long
00098 #define CAM_FLOAT2FIXED(x,dot_pos) ((CAM_FIXED_POINT)((x)*(1<<dot_pos)))
00099 
00100 #define CAM_DEPTH_SIGN 0x80000000               
00101 #define CAM_DEPTH_MASK 0x7FFFFFFF               
00102 
00103 #define CAM_DEPTH_1U     1
00104 #define CAM_DEPTH_8U     8
00105 #define CAM_DEPTH_10U   10
00106 #define CAM_DEPTH_12U   12
00107 #define CAM_DEPTH_16U   16
00108 #define CAM_DEPTH_32U   32
00109 
00110 #define CAM_DEPTH_8S  (CAM_DEPTH_SIGN| 8)
00111 #define CAM_DEPTH_10S (CAM_DEPTH_SIGN|10)
00112 #define CAM_DEPTH_12S (CAM_DEPTH_SIGN|12)
00113 #define CAM_DEPTH_16S (CAM_DEPTH_SIGN|16)
00114 #define CAM_DEPTH_32S (CAM_DEPTH_SIGN|32)
00115 
00116 #define CAM_DATA_ORDER_PIXEL  0
00117 #define CAM_DATA_ORDER_PLANE  1
00118 
00119 #define CAM_ORIGIN_TL 0
00120 
00121 #define CAM_ALIGN_4BYTES   4
00122 #define CAM_ALIGN_8BYTES   8
00123 #define CAM_ALIGN_16BYTES 16
00124 #define CAM_ALIGN_32BYTES 32
00125 
00126 #define CAM_ALIGN_DWORD   CAM_ALIGN_4BYTES
00127 #define CAM_ALIGN_QWORD   CAM_ALIGN_8BYTES
00128  
00129 #define CAM_BORDER_CONSTANT   0
00130 #define CAM_BORDER_REPLICATE  1
00131 
00132 /*---  Indexes to access IplImage.BorderMode[],IplImage.BorderConst[]  ----*/
00133 #define CAM_SIDE_TOP_INDEX    0
00134 #define CAM_SIDE_BOTTOM_INDEX 1
00135 #define CAM_SIDE_LEFT_INDEX   2
00136 #define CAM_SIDE_RIGHT_INDEX  3
00137 
00138 /*----------  values of argument of iplSetBorderMode(,,border,)  ----------*/
00139 #define CAM_SIDE_TOP        (1<<CAM_SIDE_TOP_INDEX)
00140 #define CAM_SIDE_BOTTOM     (1<<CAM_SIDE_BOTTOM_INDEX)
00141 #define CAM_SIDE_LEFT       (1<<CAM_SIDE_LEFT_INDEX)
00142 #define CAM_SIDE_RIGHT      (1<<CAM_SIDE_RIGHT_INDEX)
00143 #define CAM_SIDE_ALL        (CAM_SIDE_RIGHT | CAM_SIDE_TOP | CAM_SIDE_LEFT | CAM_SIDE_BOTTOM)
00144 
00145 #ifdef CAM_BIG_ENDIAN
00146 #define CAM_FC( ch0, ch1, ch2, ch3 ) \
00147     ((int)(ch3)|((int)(ch2)<<8)|((int)(ch1)<<16)|((int)(ch0)<<24))
00148 #else
00149 #define CAM_FC( ch0, ch1, ch2, ch3 ) \
00150     ((int)(ch0)|((int)(ch1)<<8)|((int)(ch2)<<16)|((int)(ch3)<<24))
00151 #endif
00152 
00153 #ifndef SWIG
00154 #define CAM_COLORMODEL_RGB   CAM_FC('R','G','B',000)
00155 #define CAM_COLORMODEL_RGBA  CAM_FC('R','G','B','A')
00156 #define CAM_COLORMODEL_YUV   CAM_FC('Y','U','V',000)
00157 #define CAM_COLORMODEL_GREY  CAM_FC('G',000,000,000)
00158 #define CAM_CHANNELSEQ_RGB   CAM_FC('R','G','B',000)
00159 #define CAM_CHANNELSEQ_RGBA  CAM_FC('R','G','B','A')
00160 #define CAM_CHANNELSEQ_YUV   CAM_FC('Y','U','V',000)
00161 #define CAM_CHANNELSEQ_GREY  CAM_FC('G',000,000,000)
00162 #define CAM_CHANNELSEQ_BGR   CAM_FC('B','G','R',000)
00163 #define CAM_CHANNELSEQ_BGRA  CAM_FC('B','G','R','A')
00164 #endif // SWIG
00165 
00166 #define CAM_HEADER_ONLY (1<<29)
00167 
00168 #ifdef __cplusplus
00169 struct CamImage;
00170 struct CamTableOfBasins;
00171 struct CamBitmapFont;
00172 struct CamKeypoints;
00173 struct CamKeypoint;
00174 
00176 struct CamROI {
00177 #else
00179 typedef struct {
00180 #endif
00182 
00186     int             coi;                
00187     int             xOffset;            
00188     int             yOffset;            
00189     int             width;              
00190     int             height;             
00191     
00192     // C++ Wrapping
00193 #ifdef __cplusplus
00194     CamROI() {coi=0; xOffset=0; yOffset=0; width=0; height=0;}
00195     CamROI(int _coi, int _xOffset, int _yOffset, int _width, int _height) {
00196         coi=_coi; xOffset=_xOffset; yOffset=_yOffset; width=_width; height=_height;
00197     }
00198     CamROI(const CamImage &image, int _coi=0);
00199     ~CamROI() {};
00200     CamROI intersect(const CamROI &roi) const; 
00201     bool clip(CamImage &image);
00202     bool reduce(int i);
00203     bool enlarge(int i);
00204 };
00205 
00206 struct CamLinearFilterKernel;
00207 struct CamMorphoMathsKernel;
00208 struct CamRLEImage;
00209 struct CamTable;
00210 struct CamMeasuresResults;
00211 struct CamSepFilterKernel;
00212 struct CamAffineTransform;
00213 
00215 struct CamPoint {
00216     int x; 
00217     int y; 
00218     
00219     CamPoint apply_affine_transform(const CamAffineTransform &t) const;
00220     CamPoint(int xp, int yp) {x = xp; y = yp;}
00221     CamPoint() {x = 0; y = 0;}
00222 };
00223 #else
00224 } CamROI;
00225 
00227 typedef struct {
00228     int x; 
00229     int y; 
00230 } CamPoint;
00231 #endif
00232 
00233 #define CAM_POINT   1
00234 #define CAM_CROSS   2
00235 #define CAM_CIRCLE  4
00236 
00238 
00243 #ifdef __cplusplus
00244 struct CamImage {
00245 #else
00246 typedef struct {
00247 #endif
00248 #ifdef SWIG
00249 %immutable;
00250 #endif
00251     int             nSize;              
00252     int             id;                 
00253     int             nChannels;          
00254     int             alphaChannel;       
00255     
00257 
00259     int             depth;              
00260     char            colorModel[4];      
00261     
00263 
00265     char            channelSeq[4];              
00266     int             dataOrder;          
00267     int             origin;             
00268     int             align;              
00269     int             width;              
00270     int             height;             
00271  
00272 #ifdef SWIG
00273 %mutable;
00274 #endif
00276 
00279     CamROI         *roi;
00280 #ifdef SWIG
00281 %immutable;
00282 #endif
00283 
00285 
00290     void           *mask;               
00291     
00293 
00295     void           *imageId;            
00296     
00297     void           *misc;               
00298     int             imageSize;          
00299     unsigned char  *imageData;          
00300     int             widthStep;          
00301     int             borderMode[4];      
00302     int             borderConst[4];     
00303     unsigned char  *imageDataOrigin;    
00304 
00305     // C++ Wrapping
00306 
00307 #ifdef __cplusplus
00308     CamImage() {nSize=sizeof(CamImage); imageData=NULL; roi=NULL; imageSize=0; mask=NULL; imageDataOrigin=NULL; depth=CAM_DEPTH_8U; nChannels=1; } 
00309     CamImage(int width, int height, int depth=CAM_DEPTH_8U, int channelseq=0); 
00310     CamImage(const CamImage& image);                    
00311     ~CamImage();                                        
00312 
00313 #ifndef SWIG
00314     CamImage& operator=(const CamImage &image);         
00315 #endif
00316     CamImage* clone() const;                            
00317     CamImage* copy() const;                             
00318     bool copy(CamImage &dest) const;                    
00319     bool allocated() const {return (imageData)?true:false;} 
00320     bool alloc(int width, int height, int depth=CAM_DEPTH_8U, int channelseq=0); 
00321     bool fill_header(int width, int height, int depth=CAM_DEPTH_8U, int channelseq=0); 
00322     bool deallocate();                                  
00323     bool free() {return deallocate();}
00324     bool alloc_rgb(int width, int height);              
00325     bool alloc_rgba(int width, int height);             
00326     bool alloc_bgr(int width, int height);              
00327     bool alloc_bgra(int width, int height);             
00328     bool alloc_yuv(int width, int height);              
00329     bool alloc_hls(int width, int height);              
00330     bool load_pgm(const char *filename);                
00331     bool save_pgm(const char *filename) const;          
00332     bool save_raw_pgm(const char *filename) const;      
00333     bool load_bmp(const char *filename);                
00334     bool save_bmp(const char *filename) const;          
00335     bool set_roi(const CamROI &roi);                    
00336     void get_pixels(char **result, int *len) const;     
00337     bool set_pixels(const char *pixels, int sz);        
00338     void inspect(char **result, int *len) const;        
00339     bool view() const;                                  
00340     bool set(int color);                                
00341     bool alpha_composite(const CamImage& source2, CamImage& dest) const; 
00342 
00343     int erode_square3();                                
00344     int erode_square3(CamImage &dest) const;            
00345     int erode_circle5();                                
00346     int erode_circle5(CamImage &dest) const;            
00347     int erode_circle7();                                
00348     int erode_circle7(CamImage &dest) const;            
00349     int dilate_square3();                               
00350     int dilate_square3(CamImage &dest) const;           
00351     int dilate_circle5();                               
00352     int dilate_circle5(CamImage &dest) const;           
00353     int dilate_circle7();                               
00354     int dilate_circle7(CamImage &dest) const;           
00355     int morpho_gradient_square3();                      
00356     int morpho_gradient_square3(CamImage &dest) const;  
00357     int morpho_gradient_circle5();                      
00358     int morpho_gradient_circle5(CamImage &dest) const;  
00359     int morpho_gradient_circle7();                      
00360     int morpho_gradient_circle7(CamImage &dest) const;  
00361 
00362     int morpho_maths(const CamMorphoMathsKernel &ker);                                  
00363     int morpho_maths(CamImage &dest, const CamMorphoMathsKernel &ker) const;            
00364     int erode_3x3(const CamMorphoMathsKernel &ker);                                     
00365     int erode_3x3(CamImage &dest, const CamMorphoMathsKernel &ker) const;               
00366     int dilate_3x3(const CamMorphoMathsKernel &ker);                                    
00367     int dilate_3x3(CamImage &dest, const CamMorphoMathsKernel &ker) const;              
00368     int erode_5x5(const CamMorphoMathsKernel &ker);                                     
00369     int erode_5x5(CamImage &dest, const CamMorphoMathsKernel &ker) const;               
00370     int dilate_5x5(const CamMorphoMathsKernel &ker);                                    
00371     int dilate_5x5(CamImage &dest, const CamMorphoMathsKernel &ker) const;              
00372     int erode_7x7(const CamMorphoMathsKernel &ker);                                     
00373     int erode_7x7(CamImage &dest, const CamMorphoMathsKernel &ker) const;               
00374     int dilate_7x7(const CamMorphoMathsKernel &ker);                                    
00375     int dilate_7x7(CamImage &dest, const CamMorphoMathsKernel &ker) const;              
00376 
00377     int linear_filter_3x3(const CamLinearFilterKernel &ker);                            
00378     int linear_filter_3x3(CamImage &dest, const CamLinearFilterKernel &k) const;        
00379     int linear_filter_5x5(const CamLinearFilterKernel &ker);                            
00380     int linear_filter_5x5(CamImage &dest, const CamLinearFilterKernel &k) const;        
00381     int linear_filter_abs_3x3(const CamLinearFilterKernel &ker);                        
00382     int linear_filter_abs_3x3(CamImage &dest, const CamLinearFilterKernel &k) const;    
00383     int linear_filter_abs_5x5(const CamLinearFilterKernel &ker);                        
00384     int linear_filter_abs_5x5(CamImage &dest, const CamLinearFilterKernel &k) const;    
00385     bool sobel_v();                                                                     
00386     bool sobel_h();                                                                     
00387     bool sobel_v_abs();                                                                 
00388     bool sobel_h_abs();                                                                 
00389     bool sobel_v(CamImage &dest) const;                                                 
00390     bool sobel_h(CamImage &dest) const;                                                 
00391     bool sobel_v_abs(CamImage &dest) const;                                             
00392     bool sobel_h_abs(CamImage &dest) const;                                             
00393     int sep_filter_3x3(const CamSepFilterKernel &ker);                                  
00394     int sep_filter_3x3(CamImage &dest, const CamSepFilterKernel &k) const;              
00395     int sep_filter_5x5(const CamSepFilterKernel &ker);                                  
00396     int sep_filter_5x5(CamImage &dest, const CamSepFilterKernel &k) const;              
00397     int sep_filter_7x7(const CamSepFilterKernel &ker);                                  
00398     int sep_filter_7x7(CamImage &dest, const CamSepFilterKernel &k) const;              
00399     int sep_filter_abs_3x3(const CamSepFilterKernel &ker);                              
00400     int sep_filter_abs_3x3(CamImage &dest, const CamSepFilterKernel &k) const;          
00401     int sep_filter_abs_5x5(const CamSepFilterKernel &ker);                              
00402     int sep_filter_abs_5x5(CamImage &dest, const CamSepFilterKernel &k) const;          
00403     int sep_filter_abs_7x7(const CamSepFilterKernel &ker);                              
00404     int sep_filter_abs_7x7(CamImage &dest, const CamSepFilterKernel &k) const;          
00405     bool fixed_filter(CamImage &dest, int filter) const;                                
00406     bool fixed_filter(int filter);                                                      
00407 
00408     bool draw_line(int x1, int y1, int x2, int y2, int color);                          
00409     bool accumulate_line(int x1, int y1, int x2, int y2, int acc);                      
00410     bool draw_rectangle(int x1, int y1, int x2, int y2, int color);                     
00411     bool draw_text_16s(const char *text, int x, int y, int cwidth, int cheight, int orientation, int color); 
00412     bool draw_text_bitmap(const char *text, int x, int y, const CamBitmapFont &font);   
00413     bool draw_circle(int x, int y, int r, int color);                                   
00414     bool draw_ellipse(int x, int y, int rx, int ry, int color);                         
00415     bool plot(int x, int y, int color, int kind=CAM_POINT);                             
00416     int fill_color(int x, int y, int fillcolor, int tolerance=-1);                      
00417 
00418     bool warping(CamImage &dest, int interpolation_method, bool perspective, const CamPoint &ul, const CamPoint &ur, const CamPoint &lr, const CamPoint &ll) const; 
00419     bool scale(CamImage &dest) const;                                                   
00420     bool set_mask(const CamRLEImage &mask);                                             
00421     bool set_mask(const CamImage &mask);                                                
00422     bool apply_lut(const CamTable &lut);                                                
00423     bool apply_lut(CamImage &dest, const CamTable &lut) const;                          
00424 
00425     CamImage *to_yuv() const;                                                           
00426     bool to_yuv(CamImage &dest) const;                                                  
00427     CamImage *to_y() const;                                                             
00428     bool to_y(CamImage &dest) const;                                                    
00429     CamImage *to_rgb() const;                                                           
00430     bool to_rgb(CamImage &dest) const;                                                  
00431     CamImage *to_hls() const;                                                           
00432     bool to_hls(CamImage &dest) const;                                                  
00433 
00434     CamRLEImage* encode() const;                                                        
00435     CamRLEImage* encode_lut(const CamTable &LUT)  const;                                
00436     CamRLEImage* encode_threshold(int threshold) const;                                 
00437     CamRLEImage* encode_threshold_inv(int threshold) const;                             
00438     CamRLEImage* encode_color(const CamTable &clusters) const;                          
00439     bool encode(CamRLEImage& dest) const;                                               
00440     bool encode_lut(CamRLEImage& dest, const CamTable &LUT)  const;                     
00441     bool encode_threshold(CamRLEImage& dest, int threshold) const;                      
00442     bool encode_threshold_inv(CamRLEImage& dest, int threshold) const;                  
00443 
00444     int threshold(CamImage &dest,int threshold) const;                                  
00445     int threshold_inv(CamImage &dest,int threshold) const;                              
00446     int abs(CamImage &dest) const;                                                      
00447     int threshold(int threshold);                                                       
00448     int threshold_inv(int threshold);                                                   
00449     int abs();                                                                          
00450 
00451     int arithm(int operation, int c1=0, int c2=0, int c3=0);                            
00452     int arithm(CamImage& dest, int operation, int c1=0, int c2=0, int c3=0) const;      
00453     int arithm(const CamImage& source2, CamImage& dest, int operation, int c1=0, int c2=0, int c3=0, int c4=0) const; 
00454 
00455     CamMeasuresResults measures() const;                                                
00456     float average_deviation(int average=0) const;                                       
00457 
00458     bool sum_hv(CamTable& hsum, CamTable &vsum) const;                                  
00459     bool sum_h(CamTable& sum) const;                                                    
00460     bool sum_v(CamTable& sum) const;                                                    
00461 
00462     int histogram(CamTable& histo) const;                                               
00463     bool histogram_equalization(CamImage &dest, const CamTable &src_histo, int option=0, CamImage *work=NULL); 
00464     bool histogram_2_channels(int ch1, int ch2, CamImage &result, int size=1) const;    
00465     int find_threshold(int percent) const;                                              
00466 
00467     int hough_circle(int percent, int rmin, int rmax, int &xc, int &yc, int &rc) const; 
00468 
00469     int hierarchical_watershed(CamImage &watershed, CamTableOfBasins &tob) const;       
00470     int hierarchical_watershed_contours(CamImage &ws, CamTableOfBasins &tob) const;     
00471     int hierarchical_watershed_regions(const CamTableOfBasins &tob);                    
00472 
00473     bool draw_keypoints(const CamKeypoints &points, int color = 255);           
00474     bool draw_keypoint(const CamKeypoint &point, int color = 255);              
00475     bool harris(CamKeypoints &points, int k = 41) const;                                
00476     bool integral_image(CamImage &dest) const;                                          
00477     CamImage *integral_image() const;                                                   
00478     bool fast_hessian_detector(CamKeypoints &points, int threshold, int options = 0) const; 
00479 };
00480 
00481 inline CamROI::CamROI(const CamImage &image, int _coi) { coi=_coi; xOffset=0; yOffset=0; width=image.width; height=image.height; }
00482 
00483 #else
00484 } CamImage;
00485 #endif
00486 
00487 /* Camellia C functions headers
00488  */
00489 
00490 #ifndef SWIG
00491 
00492 #define CAM_PIXEL_ACCESS(ptr,y,x) \
00493     ((CAM_PIXEL*)((char*)ptr+y*ptr##widthstep)+x)
00494 
00495 #define CAM_MAX(a,b) (((a)>(b))?(a):(b))
00496 #define CAM_MIN(a,b) (((a)<(b))?(a):(b))
00497 
00501 #define CAM_RGBA(r,g,b,a) ((r)|((g)<<8)|((b)<<16)|((a)<<24))
00502 
00507 #define CAM_RGB(r,g,b) ((r)|((g)<<8)|((b)<<16))
00508 
00509 #endif // SWIG
00510 
00511 /* General purpose structures
00512  */
00513 
00514 /* Monadic and Dyadic Arithmetic Operators kernel
00515  */
00516 
00517 #define CAM_ARITHM_ABS              0
00518 #define CAM_ARITHM_INVERSE          1
00519 #define CAM_ARITHM_SELECT           2
00520 #define CAM_ARITHM_THRESHOLD        3 
00521 #define CAM_ARITHM_DOUBLE_THRESHOLD 4
00522 
00523 #define CAM_ARITHM_ADD              0
00524 #define CAM_ARITHM_SUM              0
00525 #define CAM_ARITHM_SUB              1
00526 #define CAM_ARITHM_MUL              2
00527 #define CAM_ARITHM_ABSDIFF          3
00528 #define CAM_ARITHM_WEIGHTED_SUM     4
00529 #define CAM_ARITHM_INF              5
00530 #define CAM_ARITHM_SUP              6
00531 #define CAM_ARITHM_COMP_INF         7
00532 #define CAM_ARITHM_COMP_EQUAL       8
00533 #define CAM_ARITHM_COMP_SUP         9
00534 #define CAM_ARITHM_AND              10
00535 #define CAM_ARITHM_OR               11
00536 
00537 // Shorter constants
00538 #define CAM_ABS                     0
00539 #define CAM_INVERSE                 1
00540 #define CAM_SELECT                  2
00541 #define CAM_THRESHOLD               3 
00542 #define CAM_DOUBLE_THRESHOLD        4
00543 
00544 #define CAM_ADD                     0
00545 #define CAM_SUM                     0
00546 #define CAM_SUB                     1
00547 #define CAM_ABSDIFF                 2
00548 #define CAM_WEIGHTED_SUM            3
00549 #define CAM_INF                     4
00550 #define CAM_SUP                     5
00551 #define CAM_COMP_INF                6
00552 #define CAM_COMP_EQUAL              7
00553 #define CAM_COMP_SUP                8
00554 #define CAM_AND                     9
00555 #define CAM_OR                      10
00556 
00557 #ifndef SWIG
00558 
00560 
00563 typedef struct {
00564     int operation;   
00565     int c1; 
00566     int c2; 
00567     int c3; 
00568     int c4; 
00569 } CamArithmParams;
00570 
00571 #endif // SWIG
00572 
00573 #ifdef __cplusplus
00574 extern "C" {
00575 #endif
00576 
00577 #ifndef SWIG
00578 
00580 
00604 int camMonadicArithm(CamImage *source, CamImage *dest, CamArithmParams *params);
00605 
00607 
00646 int camDyadicArithm(CamImage *source1, CamImage *source2, CamImage *dest, CamArithmParams *params);
00647 
00649 
00650 int camAdd(CamImage *source1, CamImage *source2, CamImage *dest);
00651 
00653 
00654 int camMul(CamImage *source1, CamImage *source2, CamImage *dest);
00655 
00657 
00658 int camSub(CamImage *source1, CamImage *source2, CamImage *dest);
00659 
00661 
00663 int camThreshold(CamImage *source, CamImage *dest, int threshold);
00664 
00666 
00668 int camThresholdInv(CamImage *source, CamImage *dest, int threshold);
00669 
00671 int camAbs(CamImage *source, CamImage *dest);
00672 
00673 /* Apply-a-LUT-on-image Kernel
00674  */
00675 
00676 // 12 bits maximum LUT management
00677 #define CAM_TABLE_SIZE 4096
00678 
00679 #define CamLUT CamTable
00680 #define CamHisto CamTable
00681 
00682 #ifdef __cplusplus
00684 struct CamTable {
00685 #else
00687 typedef struct {
00688 #endif
00689     int t[CAM_TABLE_SIZE]; 
00690     int size;              
00691 #ifdef __cplusplus    
00692     CamTable(int s=0) {size=s;}
00693     int &operator[](int n);
00694     bool set(const int* const array, int sz) { if (sz<CAM_TABLE_SIZE) { size=sz; for (int i=0;i<sz;i++) t[i]=array[i]; return true;} return false;} 
00695 };
00696 #else
00697 } CamTable;
00698 #endif
00699 
00701 int camApplyLUT(CamImage *source, CamImage *dest, CamTable *LUT);
00702 
00703 #endif // SWIG
00704 
00705 /* Fundamental Morphological Mathematics Algorithms' kernel
00706  */
00707 #define CAM_MM_NEIGHB           7
00708 
00709 #define CAM_MM_DILATED          0
00710 #define CAM_MM_ERODED           1
00711 #define CAM_MM_ORIGINAL         2
00712 
00713 #define CAM_MM_SUBSTRACTION     0
00714 #define CAM_MM_MULTIPLEX        1
00715 #define CAM_MM_THINNING         2
00716 #define CAM_MM_THICKENING       3
00717 
00719 
00722 #ifdef __cplusplus
00723 struct CamMorphoMathsKernel {
00724 #else
00725 typedef struct {
00726 #endif
00727     // Structural elements
00728 #ifndef SWIG
00729     int dilationStructElt[CAM_MM_NEIGHB][CAM_MM_NEIGHB]; 
00730     int erosionStructElt[CAM_MM_NEIGHB][CAM_MM_NEIGHB];  
00731 #endif
00732     int source1;            
00733     int source2;            
00734     int operation;          
00735 #ifdef __cplusplus
00737     CamMorphoMathsKernel() {
00738         for (int i=0;i<CAM_MM_NEIGHB;i++) {
00739             for (int j=0;j<CAM_MM_NEIGHB;j++) {
00740                 dilationStructElt[i][j]=0;
00741                 erosionStructElt[i][j]=0;
00742             }
00743         }
00744         source1=CAM_MM_ORIGINAL;
00745         source2=CAM_MM_ORIGINAL;
00746         operation=CAM_MM_MULTIPLEX;
00747     }       
00749     bool set_dilate(int x, int y, int val) {
00750         if ((x>=0)&&(x<CAM_MM_NEIGHB)&&(y>=0)&&(y<CAM_MM_NEIGHB)) {
00751             dilationStructElt[x][y]=val; return true;
00752         } else return false;
00753     }
00755     int get_dilate(int x,int y) {
00756         if ((x>=0)&&(x<CAM_MM_NEIGHB)&&(y>=0)&&(y<CAM_MM_NEIGHB)) {
00757             return dilationStructElt[x][y];
00758         } else return 0;
00759     }
00761     bool set_erode(int x, int y, int val) {
00762         if ((x>=0)&&(x<CAM_MM_NEIGHB)&&(y>=0)&&(y<CAM_MM_NEIGHB)) {
00763             erosionStructElt[x][y]=val; return true;
00764         } else return false;
00765     }
00767     int get_erode(int x,int y) {
00768         if ((x>=0)&&(x<CAM_MM_NEIGHB)&&(y>=0)&&(y<CAM_MM_NEIGHB)) {
00769             return erosionStructElt[x][y];
00770         } else return 0;
00771     }
00772 };
00773 #else
00774 } CamMorphoMathsKernel;
00775 #endif
00776 
00777 #ifndef SWIG
00778 
00783 
00785 
00797 int camMorphoMaths(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel);
00798 
00799 // These are specific functions able to compute only erosion or dilation, on 3x3, 5x5 or 7x7 neighbourhood
00800 
00809 int camErode3x3(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); 
00810 
00819 int camErode5x5(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); 
00820 
00829 int camErode7x7(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); 
00830 
00839 int camDilate3x3(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); 
00840 
00849 int camDilate5x5(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); 
00850 
00859 int camDilate7x7(CamImage *source, CamImage *dest, CamMorphoMathsKernel *kernel); 
00860 
00872 int camMorphoGradientCircle5(CamImage *source, CamImage *dest); 
00873 
00883 int camErodeCircle5(CamImage *source, CamImage *dest); 
00884 
00894 int camDilateCircle5(CamImage *source, CamImage *dest);  
00895 
00907 int camMorphoGradientCircle7(CamImage *source, CamImage *dest); 
00908 
00918 int camErodeCircle7(CamImage *source, CamImage *dest); 
00919 
00929 int camDilateCircle7(CamImage *source, CamImage *dest);  
00930 
00942 int camMorphoGradientSquare3(CamImage *source, CamImage *dest); 
00943 
00953 int camErodeSquare3(CamImage *source, CamImage *dest); 
00954 
00964 int camDilateSquare3(CamImage *source, CamImage *dest); 
00965 
00966 
00967 /* Labeling kernel
00968  */
00969 #define CamLabellingResults CamLabelingResults
00970 #define camLabelling camLabeling
00971 #define camLabelling2ndScan camLabeling2ndScan
00972 #define camRLELabelling camRLELabeling
00973 
00974 #define CAM_LABEL_MAX_BLOBS 1024
00975 #define CAM_LABEL_PIXEL unsigned short
00976 
00977 #define CAM_LABEL_PIXEL_ACCESS(ptr,y,x) \
00978     ((CAM_LABEL_PIXEL*)((char*)ptr+y*ptr##widthstep)+x)
00979 
00981 typedef struct {
00982     int nbLabels;                   
00983     int equiv[CAM_LABEL_MAX_BLOBS]; 
00984 } CamLabelingResults;
00985 
00987 
01000 int camLabeling(CamImage *source, CamImage *dest, CamLabelingResults *results); 
01001                                                                                   
01006 int camLabeling2ndScan(CamImage *image, CamLabelingResults *results); 
01007 
01008 /* Blob analysis Kernel
01009  * C code */
01010 
01011 #endif // SWIG
01012 
01013 #define CAM_RLE_INT_TYPE unsigned short
01014 
01016 
01018 typedef struct {
01019     CAM_RLE_INT_TYPE value;     
01020     CAM_RLE_INT_TYPE length;    
01021     CAM_RLE_INT_TYPE blob;      
01022     CAM_RLE_INT_TYPE line;      
01023 } CamRun;
01024 
01025 #ifndef SWIG
01026 
01028 typedef struct {
01029     int id;
01030     int left;           
01031     int top;            
01032     int width;          
01033     int height;         
01034     int surface;        
01035     int cx;             
01036     int cy;             
01037     int value;          
01038     int min;            
01039     int max;            
01040     CamRun *first;      
01041     CamRun *last;       
01042     void *misc;         
01043 } CamBlobInfo;
01044 
01045 #define CamBlobAnalysisResults CamBlobs // For compatibility with previous versions
01046 
01047 #ifdef __cplusplus
01049 struct CamBlobs {
01050     int nbBlobs;                                
01051     CamBlobInfo blobInfo[CAM_LABEL_MAX_BLOBS];  
01052     CamBlobs() {nbBlobs=0;}                     
01053     CamBlobInfo& operator[](int index);
01054 };
01055 #else
01057 typedef struct {
01058     int nbBlobs;                                
01059     CamBlobInfo blobInfo[CAM_LABEL_MAX_BLOBS];  
01060 } CamBlobs;
01061 #endif
01062 
01077 int camBlobAnalysis1stScan(CamImage *blobImage, CamImage *original, CamLabelingResults *info, CamBlobs *results); 
01078 
01080 
01089 int camBlobAnalysisRefinement(CamImage *blobImage, CamImage *original, CamBlobs *results);
01090 
01091 /* RLE Labeling kernel
01092  * New : v1.4 of LLAs
01093  * Updated v1.6 and v1.9, v2.0 of LLAs
01094  */
01095 
01099 
01100 #ifdef __cplusplus
01102 struct CamRLEImage {
01103 #else
01105 typedef struct {
01106 #endif
01107     int nSize;          
01108     int id;             
01109     int height;         
01110     int width;          
01111     int nbRuns;         
01112     int allocated;      
01113     CamRun *runs;       
01114 
01115 #ifdef __cplusplus
01116     CamRLEImage() {nSize=sizeof(CamRLEImage); allocated=0; runs=NULL; nbRuns=0;} 
01117     CamRLEImage(int nbruns);                            
01118     CamRLEImage(const CamRLEImage &image);              
01119     ~CamRLEImage();                                     
01120 
01121     CamRLEImage& operator=(const CamRLEImage &image);   
01122     CamRLEImage* clone() const;                         
01123     bool alloc(int nbruns);                             
01124     bool realloc(int nbruns);                           
01125 
01126     bool encode(const CamImage &image);                             
01127     bool encode_lut(const CamImage &image, const CamTable &LUT);    
01128     bool encode_threshold(const CamImage &image, int threshold);    
01129     bool encode_threshold_inv(const CamImage &image, int threshold);
01130     bool encode_color(const CamImage &image, const CamTable &clusters); 
01131     CamBlobs* labeling();                                           
01132     bool labeling(CamBlobs &results);                               
01133     bool blob_analysis(CamBlobs &results) const;                    
01134     bool apply_lut(const CamTable &LUT);                            
01135     bool apply_lut(CamRLEImage &dest, const CamTable &LUT) const;   
01136     bool decode(CamImage &dest) const;                              
01137     bool decode(CamImage &dest, const CamTable &LUT) const;         
01138     bool decode_blobs(CamImage &dest) const;                        
01139     bool decode_blobs(CamImage &dest, const CamTable &LUT) const;   
01140     bool inverse();                                                 
01141     bool erode_cross(CamRLEImage &dest) const;                      
01142     CamRLEImage *erode_cross() const;                               
01143     bool erode_3x3(CamRLEImage &dest) const;                        
01144     CamRLEImage *erode_3x3() const;                                 
01145     bool erode_3x2(CamRLEImage &dest) const;                        
01146     CamRLEImage *erode_3x2() const;                                 
01147 };
01148 #else
01149 } CamRLEImage;
01150 #endif
01151 
01153 
01174 int camRLEAllocate(CamRLEImage *rle, int max_runs);
01175 
01177 
01185 int camRLEDeallocate(CamRLEImage *rle);
01186 
01188 int camRLEFree(CamRLEImage *rle);
01189 
01191 
01200 int camRLEReallocate(CamRLEImage *rle, int new_max_runs);
01201 
01203 
01211 int camRLEClone(CamRLEImage *source, CamRLEImage *dest);
01212 
01214 
01224 int camRLEEncode(CamImage *src, CamRLEImage *dest);
01225 
01227 
01237 int camRLEEncodeLUT(CamImage *src, CamRLEImage *dest, CamTable *LUT);
01238 
01240 
01248 int camRLEEncodeThreshold(CamImage *src, CamRLEImage *dest, int threshold);
01249 
01251 
01259 int camRLEEncodeThresholdInv(CamImage *src, CamRLEImage *dest, int threshold);
01260 
01261 int camRLEEncodeColor(CamImage *source, CamRLEImage *dest, CamTable *clusters);
01262 
01264 
01288 int camRLELabeling(CamRLEImage *src, CamBlobs *results);
01289 
01291 
01298 int camRLEBlobAnalysis(CamRLEImage *src, CamBlobs *results);
01299 
01301 
01311 int camRLEApplyLUT(CamRLEImage *src, CamRLEImage *dest, CamTable *LUT);
01312 
01314 
01325 int camRLEDecode(CamRLEImage *src, CamImage *dest, CamTable *LUT);
01326 
01328 
01339 int camRLEDecodeBlobs(CamRLEImage *src, CamImage *dest, CamTable *LUT);
01340 
01342 
01346 int camRLEInverse(CamRLEImage *image);
01347 
01349 int camRLEBlobSides(CamBlobInfo *blob, int *left, int *top, int *right, int *bottom);
01350 
01352 int camRLEBlobROIIntersect(CamBlobInfo *blob, CamROI *roi);
01353 
01355 int camRLEBlobMeasures(CamBlobInfo *blob, CamImage *original);
01356 
01358 
01363 int camRLEErodeCross(CamRLEImage *image, CamRLEImage *result);
01364 
01366 
01371 int camRLEErode3x3(CamRLEImage *image, CamRLEImage *result);
01372 
01374 
01379 int camRLEErode3x2(CamRLEImage *image, CamRLEImage *result);
01380 
01382 
01386 
01388 
01398 int camHistogram(CamImage *image, CamTable *histo);
01399 
01400 #define CAM_EQUAL_PERFECT 0
01401 #define CAM_EQUAL_FAST    1
01402 
01404 
01415 int camHistogramEqualization(CamImage *src, CamImage *dest, CamTable *src_histo, int option, CamImage *work);
01416 
01418 
01427 int camHistogram2Channels(CamImage *image, int ch1, int ch2, CamImage *result, int size);
01428 
01430 int camFindThreshold(CamTable *histo, int percent);
01432 
01433 /* Horizontal and vertical summing
01434  */
01435 
01437 
01445 int camSumHV(CamImage *image, CamTable *hsum, CamTable *vsum);
01446 
01448 
01455 int camSumV(CamImage *image, CamTable *results);
01456 
01458 
01465 int camSumH(CamImage *image, CamTable *results);
01466 
01467 #endif // SWIG
01468 
01469 /* Measures in an image : min, max, average computation
01470  */
01471 #ifdef __cplusplus
01473 struct CamMeasuresResults {
01474 #else
01476 typedef struct {
01477 #endif
01478     int min, xmin, ymin;        
01479     int max, xmax, ymax;        
01480     int average;                
01481     int sum;                    
01482 #ifdef __cplusplus
01483     CamMeasuresResults() {min=0;xmin=0;ymin=0;max=0;xmax=0;ymax=0;average=0;sum=0;}
01484 };
01485 #else
01486 } CamMeasuresResults;
01487 #endif
01488 
01489 #ifndef SWIG
01490 
01492 int camSumOfPixels(CamImage *image);
01493 
01495 
01501 int camMeasures(CamImage *image, CamMeasuresResults *results);
01502 
01504 
01512 float camMeasureAverageDeviation(CamImage *image, int average);
01513 
01517 
01519 
01527 #ifdef CAM_VOLBERG_ORIGINAL
01528 void volbergfvd(double f[], int in[] , int out[] , int inlen, int outlen);
01529 #else
01530 void camVolbergFwdScanline(CAM_PIXEL *in, int inlen, CAM_PIXEL *out, int outlen, double f[]);
01531 #endif
01532 
01534 typedef struct {
01535     void (*hfwd)(int x, int y, double *xp); 
01536     void (*vfwd)(int x, int y, double *yp); 
01537 } CamVolbergFwdParams;
01538 
01540 
01545 void camVolbergFwd(CamImage *source, CamImage *dest, CamVolbergFwdParams *params);
01546 
01547 /* Backward warping
01548  */
01549 
01550 #endif // SWIG
01551 
01552 #define CAM_NN_INTERPOLATION 0
01553 #define CAM_BILINEAR_INTERPOLATION 1
01554 
01555 #ifndef SWIG
01556 
01558 typedef struct {
01559     int interpolation;  
01560     int perspective;    
01561     
01563 
01571     CamPoint p[4];
01572 } CamWarpingParams;
01573 
01575 
01584 int camWarping(CamImage *source, CamImage *dest, CamWarpingParams *params);
01585 
01587 
01593 int camScale(CamImage *source, CamImage *dest);
01594 
01595 int camWarpingSuperSampling(CamImage *source, CamImage *dest, CamWarpingParams *params);
01596 
01598 
01604 int camIntersectionSegments(CamPoint p[4], CamPoint *res);
01606 
01610 
01611 // For compatibility with older versions
01612 #define CamSobel3x3 camSobel
01613 #define CamSobelAbs3x3 camSobelAbs
01614 
01615 #define CAM_LINEAR_FILTER_KERNEL_MAX_SIZE 7
01616 
01617 #endif //SWIG
01618 
01619 #ifdef __cplusplus
01621 struct CamLinearFilterKernel {
01622 #else
01624 typedef struct {
01625 #endif
01626 #ifndef SWIG
01627     int kernel[CAM_LINEAR_FILTER_KERNEL_MAX_SIZE][CAM_LINEAR_FILTER_KERNEL_MAX_SIZE]; 
01628 #endif
01629     int coeff1;         
01630     int coeff2;         
01631 #ifdef __cplusplus
01633     CamLinearFilterKernel() {
01634         for (int i=0;i<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE;i++) {
01635             for (int j=0;j<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE;j++) {
01636                 kernel[i][j]=0;
01637             }
01638         }
01639         coeff1=1;
01640         coeff2=0;
01641     }       
01643     bool set(int x, int y, int val) {
01644         if ((x>=0)&&(x<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)&&(y>=0)&&(y<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
01645             kernel[x][y]=val; return true;
01646         } else return false;
01647     }
01649     int get(int x,int y) {
01650         if ((x>=0)&&(x<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)&&(y>=0)&&(y<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
01651             return kernel[x][y];
01652         } else return 0;
01653     }
01654 };
01655 #else
01656 } CamLinearFilterKernel;
01657 #endif
01658 
01659 #ifndef SWIG
01660 
01662 
01673 int camLinearFilter3x3(CamImage *source, CamImage *dest, CamLinearFilterKernel *params);
01674 
01676 
01687 int camLinearFilter5x5(CamImage *source, CamImage *dest, CamLinearFilterKernel *params);
01688 
01690 
01701 int camLinearFilterAbs3x3(CamImage *source, CamImage *dest, CamLinearFilterKernel *params);
01702 
01704 
01715 int camLinearFilterAbs5x5(CamImage *source, CamImage *dest, CamLinearFilterKernel *params);
01716 
01717 /* Obsolete
01718  * int camSobel(CamImage *source, CamImage *dest, int vert_edges);
01719  * int camSobelAbs(CamImage *source, CamImage *dest, int vert_edges);
01720  */
01721 
01722 #endif //SWIG
01723 
01724 #ifdef __cplusplus
01726 struct CamSepFilterKernel {
01727 #else
01729 typedef struct {
01730 #endif
01731 #ifndef SWIG
01732     int x[CAM_LINEAR_FILTER_KERNEL_MAX_SIZE]; 
01733     int y[CAM_LINEAR_FILTER_KERNEL_MAX_SIZE]; 
01734 #endif
01735     int coeff1;         
01736     int coeff2;         
01737 #ifdef __cplusplus
01739     CamSepFilterKernel() {
01740         for (int i=0;i<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE;i++) {
01741             x[i]=0; y[i]=0;
01742         }
01743         coeff1=1;
01744         coeff2=0;
01745     }       
01747     bool set_x(int y, int val) {
01748         if ((y>=0)&&(y<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
01749             x[y]=val; return true;
01750         } else return false;
01751     }
01752     bool set_y(int x, int val) {
01753         if ((x>=0)&&(x<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
01754             y[x]=val; return true;
01755         } else return false;
01756     }
01758     int get_x(int y) {
01759         if ((y>=0)&&(y<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
01760             return x[y];
01761         } else return 0;
01762     }
01763     int get_y(int x) {
01764         if ((x>=0)&&(x<CAM_LINEAR_FILTER_KERNEL_MAX_SIZE)) {
01765             return y[x];
01766         } else return 0;
01767     }
01768 };
01769 #else
01770 } CamSepFilterKernel;
01771 #endif
01772 
01773 #define CAM_SOBEL_H         1
01774 #define CAM_SOBEL_V         2
01775 #define CAM_GAUSSIAN_3x3    3
01776 #define CAM_GAUSSIAN_5x5    4
01777 #define CAM_GAUSSIAN_7x7    5
01778 #define CAM_SCHARR_H        6
01779 #define CAM_SCHARR_V        7
01780 
01781 #ifndef SWIG
01782 
01784 
01794 int camSepFilter3x3(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
01795 
01797 
01807 int camSepFilterAbs3x3(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
01808 
01810 
01820 int camSepFilter5x5(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
01821 
01823 
01833 int camSepFilterAbs5x5(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
01834 
01836 
01846 int camSepFilter7x7(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
01847 
01849 
01859 int camSepFilterAbs7x7(CamImage *source, CamImage *dest, CamSepFilterKernel *kernel);
01860 
01862 
01871 int camSobelH(CamImage *source, CamImage *dest);
01872 
01874 
01883 int camSobelHAbs(CamImage *source, CamImage *dest);
01884 
01886 
01895 int camSobelV(CamImage *source, CamImage *dest);
01896 
01898 
01907 int camSobelVAbs(CamImage *source, CamImage *dest);
01908 
01910 
01931 int camFixedFilter(CamImage *source, CamImage *dest, int filter);
01932 
01933 int camScharrH(CamImage *source, CamImage *dest);
01934 int camScharrV(CamImage *source, CamImage *dest);
01935 int camScharrHAbs(CamImage *source, CamImage *dest);
01936 int camScharrVAbs(CamImage *source, CamImage *dest);
01937 
01939 
01943 
01944 #define camMedianFiltering3x3 camMedianFilter3x3
01945 #define camMedianFiltering5x5 camMedianFilter5x5
01946 
01948 
01957 int camMedianFilter3x3(CamImage *source, CamImage *dest);
01958 
01960 
01969 int camMedianFilter5x5(CamImage *source, CamImage *dest);
01971 
01975 
01977 
01994 int camWatershed1D(int *input, int size, int *results);
01995 #else
01996 %immutable;
01997 #endif // SWIG
01998 
02000 typedef struct 
02001 {
02002    int dynamics;        
02003    int minimum;         
02004    int flooded;         
02005    int surface;         
02006    int accsurface;      
02007    unsigned short x,y;  
02008 } CamBasin;
02009 
02010 #define CAM_NOT_COMPUTED 65536
02011 
02012 #ifndef SWIG
02013 #ifdef __cplusplus
02015 struct CamTableOfBasins {
02016     int sizeMax;
02017     int nbBasins;
02018     CamBasin *tab;
02019     CamBasin& operator[](int index) {return tab[index];}
02020     void get_rid_of(CamBasin &basin) {basin.surface=0;}
02021     CamTableOfBasins() {tab=NULL;sizeMax=0;nbBasins=0;}
02022     ~CamTableOfBasins();
02023 };
02024 #else
02025 typedef struct
02026 {
02027    int sizeMax;
02028    int nbBasins;
02029    CamBasin *tab;
02030 } CamTableOfBasins;
02031 #endif
02032 
02034 void camFreeTableOfBasins(CamTableOfBasins *t);
02035 
02037 
02053 int camHierarchicalWatershed(CamImage *source, CamImage *dest, CamTableOfBasins *tob);
02054 
02056 
02073 int camHierarchicalWatershedContours(CamImage *source, CamImage *dest, CamTableOfBasins *tob);
02074 
02076 
02082 int camHierarchicalWatershedRegions(CamImage *watershed, CamTableOfBasins *tob);
02084 
02088 
02090 
02102 int camHoughCircle(CamImage *image, int percent, int rmin, int rmax, int *xc, int *yc, int *rc);
02103 
02104 struct _CamKeypoints;
02105 
02106 #endif // SWIG 
02107 
02111 
02112 #ifdef __cplusplus
02113 #ifdef SWIG
02114     %mutable;
02115 #endif
02116 
02118 struct CamKeypoint {
02119 #else
02120 typedef struct {
02121 #endif // __cplusplus
02122     int descriptor[128];    
02123     int x;                  
02124     int y;                  
02125     int scale;              
02126     int angle;              
02127     int value;              
02128 #ifdef SWIG
02129     %immutable;
02130 #endif
02131     int size;               
02132     void *internal;         
02133 #ifdef __cplusplus
02134     CamKeypoints *set;
02135     bool draw(CamImage &image, int color = 255) const;   
02136     bool set_descriptor(const int* const array, int sz); 
02137     CamKeypoint() { x = 0; y = 0; scale = 0; angle = 0; value = 0; size = 0; internal = NULL; set = NULL; }
02138 };
02139 #else
02140     struct _CamKeypoints *set;
02141 } CamKeypoint;
02142 #endif
02143 
02144 typedef struct {
02145     CamKeypoint *p1;
02146     CamKeypoint *p2;
02147     int mark;
02148     int error;
02149 } CamKeypointsMatch;
02150 
02151 #define CAM_MAX_NB_MATCHES 2048
02152 
02153 #ifdef __cplusplus
02155 struct CamAffineTransform {
02156     double m[6];
02157 };
02158 
02160 struct CamKeypointsMatches {
02161 #else
02162 
02163 typedef struct {
02164     double m[6];
02165 } CamAffineTransform;
02166 
02167 typedef struct {
02168 #endif //__cplusplus
02169     int nbMatches;
02170     int nbOutliers;
02171     int allocated;
02172     CamKeypointsMatch *pairs;
02173 #ifdef __cplusplus
02174     CamKeypointsMatches(int size = CAM_MAX_NB_MATCHES);             
02175     ~CamKeypointsMatches();                                         
02176     CamAffineTransform find_affine_transform(int *error) const;     
02177     CamAffineTransform find_affine_transform2(int *error) const;    
02178 };
02179 #else
02180 } CamKeypointsMatches;
02181 #endif
02182 
02183 #ifdef __cplusplus
02184 struct CamKeypointsKdTree;
02185 
02186 #ifdef SWIG
02187     %mutable;
02188 #endif
02190 struct CamKeypoints {
02191 #else
02193 typedef struct _CamKeypoints {
02194 #endif
02195     int width, height;              
02196     int cx, cy;                     
02197     int id;                         
02198 #ifdef SWIG
02199     %immutable;
02200 #endif
02201     int allocated;
02202     int nbPoints;                   
02203     CamKeypoint **keypoint; 
02204     CamKeypoint *bag;       
02205 #ifdef __cplusplus
02206     CamKeypoints() {allocated = 0; nbPoints = 0; keypoint = NULL; bag = NULL; cx = 0; cy = 0;} 
02207     CamKeypoints(int nbPoints);                 
02208 #ifndef SWIG
02209     CamKeypoint& operator[](int index);
02210 #endif
02211     ~CamKeypoints();                                
02212 
02213     bool add(CamKeypoint &p);
02214     CamKeypoints& operator<<(CamKeypoint &p) { add(p); return *this; }
02215     bool draw(CamImage &image, int color = 255) const;  
02216     int matching(const CamKeypoints **models, int nbModels, CamKeypointsMatches &matches) const;  
02217     int matching2(const CamKeypoints &points, CamKeypointsMatches &matches) const;                
02218     int matchingKdTree(const CamKeypointsKdTree &kdTree, CamKeypointsMatches &matches, int explore = 100) const; 
02219 
02220     bool alloc(int nbPoints);                           
02221     bool realloc(int nbPoints);                         
02222 };
02223 #else
02224 } CamKeypoints;
02225 #endif
02226 
02227 #define CAM_UPRIGHT 1
02228 
02229 int camKeypointsSetParameters(int patchSize, int sigma, int threshGradient);
02230 
02231 #ifndef SWIG
02232 
02234 int camAllocateKeypoints(CamKeypoints *fpoints, int nbPoints);
02235 
02237 int camReallocateKeypoints(CamKeypoints *fpoints, int nbPoints);
02238 
02240 int camFreeKeypoints(CamKeypoints *fpoints);
02241 
02243 int camDrawKeypoints(CamKeypoints *points, CamImage *dest, int color);
02244 
02246 int camDrawKeypoint(CamKeypoint *point, CamImage *dest, int color);
02247 
02249 
02251 int camHarris(CamImage *source, CamKeypoints *points, int k);
02252 
02254 int camFindLocalMaximaCircle7(CamImage *source, CamKeypoints *points, int threshold);
02255 
02257 int camFindLocalMaximaCircle5(CamImage *source, CamKeypoints *points, int threshold);
02258 
02260 int camFindLocalMaximaCircle3(CamImage *source, CamKeypoints *points, int threshold);
02261 
02263 int camIntegralImage(CamImage *src, CamImage *dest);
02264 
02266 int camFastHessianDetectorFixedScale(CamImage *integral, CamImage *dest, int scale);
02267 
02269 int camFastHessianDetector(CamImage *source, CamKeypoints *points, int threshold, int options);
02270 
02272 CamKeypoint* camFindKeypoint(CamKeypoint *point, CamKeypoints *points, int *dist1, int *dist2);
02273 
02275 int camAllocateKeypointsMatches(CamKeypointsMatches *matches, int nbpairs);
02276 
02278 void camFreeKeypointsMatches(CamKeypointsMatches *matches);
02279 
02281 int camKeypointsMatching(CamKeypoints *target, CamKeypoints **models, int nbModels, CamKeypointsMatches *matches);
02282 int camKeypointsMatching2(CamKeypoints *points1, CamKeypoints *points2, CamKeypointsMatches *matches);
02283 
02285 int camFindAffineTransform(CamKeypointsMatches *matches, CamAffineTransform *t, int *error);
02286 int camFindAffineTransform2(CamKeypointsMatches *matches, CamAffineTransform *t, int *error);
02287 
02289 void camApplyAffineTransform(CamPoint *xy, CamPoint *uv, CamAffineTransform *t);
02290 
02291 typedef struct _CamFPKdTreeNode {
02292     int i;
02293     int m;
02294     struct _CamFPKdTreeNode *right;
02295 } CamFPKdTreeNode;
02296 
02297 int camKeypointsMatchingKdTree(CamKeypoints *target, CamFPKdTreeNode *kdTreeRoot, CamKeypointsMatches *matches, int explore);
02298 
02299 CamFPKdTreeNode *camKeypointsCompileKdTree(CamKeypoints **models, int nbModels);
02300 
02301 CamKeypoint *camFindKeypointKdTree(CamKeypoint *point, CamFPKdTreeNode *kdTreeRoot, int explore, int *dist1, int *dist2);
02302 
02303 #endif // SWIG
02304 
02305 #ifdef __cplusplus
02307 struct CamKeypointsKdTree {
02308     CamFPKdTreeNode *root;
02309 
02310     void compile(const CamKeypoints **models, int nbModels) {root = camKeypointsCompileKdTree((CamKeypoints**)models, nbModels);}
02311     CamKeypoint *find(const CamKeypoint *point, int explore = 100, int *dist1 = NULL, int *dist2 = NULL) const; // C++ Wrapper for camFindKeypointKdTree function
02312 
02313     CamKeypointsKdTree(const CamKeypoints **models = NULL, int nbModels = 0) { if (nbModels != 0) compile(models, nbModels); else root = NULL;};
02314     ~CamKeypointsKdTree() {if (root) free(root);}       
02315 };
02316 #endif // __cplusplus
02317 
02319 
02323 
02324 /* Image allocation utility routines
02325  */
02326 
02327 #ifndef SWIG
02328 
02330 int camAllocateImage(CamImage *image, int width, int height, int depth);
02332 int camAllocateImageEx(CamImage *image, int width, int height, int depth, int color_seq);
02334 int camFillImageHeader(CamImage *image, int width, int height, int depth, int channelseq);
02336 int camAllocateYUVImage(CamImage *image, int width, int height);
02338 int camAllocateHLSImage(CamImage *image, int width, int height);
02340 int camAllocateRGBImage(CamImage *image, int width, int height);
02342 int camAllocateRGBAImage(CamImage *image, int width, int height);
02344 int camAllocateBGRImage(CamImage *image, int width, int height);
02346 int camAllocateBGRAImage(CamImage *image, int width, int height);
02348 int camDeallocateImage(CamImage *image);
02350 int camFreeImage(CamImage *image);
02351 
02352 /* Other useful functions
02353  */
02355 int camSetROI(CamROI *roi, int coi, int xOffset, int yOffset, int width, int height);
02357 int camSetMaxROI(CamROI *roi, CamImage *image);
02359 int camReduceROI(CamROI *roi, int pixels);
02361 int camEnlargeROI(CamROI *roi, int pixels);
02363 int camZoom2x(CamImage *src, CamImage *dst);
02365 int camDecimateNN(CamImage *src, CamImage *dest, int factor);
02367 int camSetRLEMask(CamImage *image, CamRLEImage *mask);
02369 int camSetMask(CamImage *image, CamImage *mask);
02370 
02371 #define camDownScaling2x2 camDownscaling2x2
02373 int camDownScaling2x2(CamImage *src, CamImage *dest);
02375 
02379 int camCopy(CamImage *source, CamImage *dest);
02381 
02384 int camClone(CamImage *source, CamImage *dest);
02386 
02389 int camRefCopy(CamImage *source, CamImage *dest);
02391 int camSet(CamImage *image, int fillValue);
02393 
02397 int camAlphaComposite(CamImage *source1, CamImage *source2, CamImage *dest);
02398 
02400 int camSetBorder(CamImage *image, int borderValue);
02402 int camClipROI(CamImage *image);
02404 int camClip(CamROI *roi, CamImage *image);
02406 int camROIIntersect(CamROI *roi1, CamROI *roi2, CamROI *dest);
02407 
02408 #endif //SWIG
02409 int camSetImageViewer(char *s);
02410 #ifndef SWIG
02411 
02413 int camView(CamImage *image);
02415 const char *camVersion();
02416 
02417 /* Drawing functions
02418  */
02420 int camDrawLine(CamImage *image, int x1, int y1, int x2, int y2, int color);
02422 int camAccumulateLine(CamImage *image, int x1, int y1, int x2, int y2, int acc);
02424 int camDrawRectangle(CamImage *image, int x1, int y1, int x2, int y2, int color);
02426 int camDrawText16s(CamImage *image, char *text, int x, int y, int cwidth, int cheight, int orientation, int color);
02428 int camDrawCircle(CamImage *image, int x, int y, int r, int color);
02430 int camDrawEllipse(CamImage *image, int x, int y, int rx, int ry, int color);
02432 
02434 int camPlot(CamImage *image, int x, int y, int color, int kind);
02436 
02447 int camFillColor(CamImage *image, int x, int y, int fillcolor, int tolerance);
02448 
02449 #endif // SWIG
02450 
02451 #ifdef __cplusplus
02453 struct CamBitmapFont {
02454 #else
02455 typedef struct {
02456 #endif
02457     int first_char;
02458     int nb_chars;
02459     int height;
02460     CamRLEImage *masks;
02461     CamImage *letters;
02462 #ifdef __cplusplus
02463     CamBitmapFont() {first_char=33; nb_chars=0; masks=NULL; letters=NULL;}
02464     CamBitmapFont(const char *filename);
02465     ~CamBitmapFont();
02466     bool load(const char *filename);
02467 };
02468 #else
02469 } CamBitmapFont;
02470 #endif
02471 
02472 #ifndef SWIG
02474 int camLoadBitmapFont(CamBitmapFont *font, char *filename);
02476 int camFreeBitmapFont(CamBitmapFont *font);
02478 int camDrawTextBitmap(CamImage *image, char *text, int x, int y, CamBitmapFont *font);
02479 #endif // SWIG
02480 
02482 
02484 int camRGB(int r, int g, int b);
02485 
02487 int camRGBA(int r, int g, int b, int a);
02488 
02489 #ifndef SWIG
02490 
02491 /* Load and save PGM images
02492  */
02494 int camLoadPGM(CamImage *image, char *fn);
02496 int camSavePGM(CamImage *image, char *filename);
02498 int camSaveRawPGM(CamImage *image, char *filename);
02499 
02500 /* Load and save BMP images
02501  */
02503 int camLoadBMP(CamImage *image, char *fn);
02505 int camSaveBMP(CamImage *image, char *filename);
02506 
02507 /* Load config files
02508  */
02509 #define CAM_CONFIG_MAX_ENTRIES 256
02510 typedef struct {
02511     int nbEntries;
02512     char parameter[CAM_CONFIG_MAX_ENTRIES][128];
02513     char value[CAM_CONFIG_MAX_ENTRIES][128];
02514 } CamConfig;
02515 
02516 int camLoadConfig(const char *filename, CamConfig *config);
02517 int camConfigInt(const CamConfig *config, const char *entry);
02518 float camConfigFloat(const CamConfig *config, const char *entry);
02519 const char *camConfigString(const CamConfig *config, const char *entry);
02520 
02521 /* Image capture functions
02522  */
02523 void* camCaptureInit(int options);
02524 int camCapture(void *handle, CamImage *image);
02525 int camCaptureOver(void *handle);
02526 
02527 #endif
02528 
02529 #define CAM_CAPTURE_AUTO_SOURCE 1
02530 #define CAM_CAPTURE_DISPLAY     2
02531 #define CAM_CAPTURE_USE_READ    4
02532 
02533 #ifdef __cplusplus
02534 class CamCapture {
02535     void *handle;
02536 public:
02537     bool capture(CamImage &capture);
02538     bool ready() {return (handle)?true:false;}
02539     CamCapture(int options=0);
02540     ~CamCapture();
02541 };
02542 #endif
02543 
02544 #ifndef SWIG
02545 
02547 void camError(char *module, char *error);
02548 typedef void (*camErrorFunct)(char *,char*);
02549 void camSetErrorFunct(camErrorFunct funct);
02551 
02555 int camYUV2RGB(CamImage* source, CamImage *dest); 
02556 int camRGB2YUV(CamImage* source, CamImage *dest); 
02557 int camRGB2Y(CamImage *source, CamImage *dest);   
02558 int camRGB2HLS(CamImage* source, CamImage *dest); 
02559 
02560 
02564 /*
02565  * Computes the Sum of Absolute Values between two 8x8 blocks
02566  *
02567  * This function takes into account the blocks lying partially outside the image.
02568  * MMX optimized if <DFN>CAM_OPT_MMX</DFN> compilation option is set (requires Intel C++ compiler).
02569  *
02570  *
02571  * \param image1    Current image
02572  * \param image2    Previous image
02573  * \param bleft     The x coordinate of the current block
02574  * \param btop      The y coordinate of the current block
02575  * \param dx        The x offset to reach the candidate block
02576  * \param dy        The y offset to reach the candidate block
02577  *
02578  * \return The SAD value between the given two blocks
02579  */
02580 int camSAD8x8(CamImage *image1, CamImage *image2, int bleft, int btop, int dx, int dy);
02581 
02582 /*
02583  * Computes the Sum of Absolute Values between two 16x16 blocks
02584  *
02585  * This function takes into account the blocks lying partially outside the image.
02586  * MMX optimized if <DFN>CAM_OPT_MMX</DFN> compilation option is set (requires Intel C++ compiler).
02587  *
02588  *
02589  * \param image1    Current image
02590  * \param image2    Previous image
02591  * \param bleft     The x coordinate of the current block
02592  * \param btop      The y coordinate of the current block
02593  * \param dx        The x offset to reach the candidate block
02594  * \param dy        The y offset to reach the candidate block
02595  *
02596  * \return The SAD value between the given two blocks
02597  */
02598 int camSAD16x16(CamImage *image1, CamImage *image2, int bleft, int btop, int dx, int dy);
02599 
02600 typedef struct {
02601     int niter;          
02602     int seed;           
02603     int lsearch;        
02604     int rsearch;        
02605     int blockSize;      
02606     int scans;          
02607     int candidates;     
02608     int test0;          
02609 } CamMotionEstimation3DRSParams;
02610 
02611 typedef struct {
02612     int vx[CAM_MAX_SCANLINE/8][CAM_MAX_FRAME_HEIGHT/8];   
02613     int vy[CAM_MAX_SCANLINE/8][CAM_MAX_FRAME_HEIGHT/8];   
02614     int SAD[CAM_MAX_SCANLINE/8][CAM_MAX_FRAME_HEIGHT/8];  
02615 } CamMotionEstimation3DRSResults;
02616 
02617 int camMotionEstimation3DRSInit(CamMotionEstimation3DRSParams *params, int seed, int lsearch, int rsearch, int bs, int scans, int candidates, int test0);
02618 int camMotionEstimation3DRS(CamImage *current, CamImage *previous, CamMotionEstimation3DRSParams *params, CamMotionEstimation3DRSResults *results);
02620 
02624 
02625 void camProject(const double extr[4][4], const double fc[2], const double cc[2], double x, double y, double z, int *xp, int *yp);
02626 
02627 void camBackproject(const double extr[4][4], const double fc[2], const double cc[2], int xp, int yp, double z, double *x, double *y);
02628 
02629 int camUndistort(CamImage *source, CamImage *dest,
02630                  const float* intrinsic_matrix,
02631                  const float* dist_coeffs);
02632 int camUndistortFixed(CamImage *source, CamImage *dest,
02633                       const CAM_FIXED_POINT* intrinsic_matrix,
02634                       const CAM_FIXED_POINT* dist_coeffs);
02635 int camUndistortBuildLUT(CamImage *source,
02636                          const float* intrinsic_matrix,
02637                          const float* dist_coeffs,
02638                          CamImage *LUTX, CamImage *LUTY);
02639 int camUndistortLUT(CamImage *source, CamImage *dest,
02640                     CamImage *LUTX, CamImage *LUTY);
02641 
02643 
02644 #endif // SWIG
02645 
02646 #ifdef __cplusplus
02647 }
02648 #endif
02649 
02650 #endif
02651 

Generated on Thu Jan 3 16:41:07 2008 for Camellia by  doxygen 1.5.3