7964cd35b0e8017eb9540d4fe1a669a215cb5af4
[platform/upstream/opencv.git] / modules / legacy / src / _vm.h
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 //  By downloading, copying, installing or using the software you agree to this license.
6 //  If you do not agree to this license, do not download, install,
7 //  copy or use the software.
8 //
9 //
10 //                        Intel License Agreement
11 //                For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
15 //
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
18 //
19 //   * Redistribution's of source code must retain the above copyright notice,
20 //     this list of conditions and the following disclaimer.
21 //
22 //   * Redistribution's in binary form must reproduce the above copyright notice,
23 //     this list of conditions and the following disclaimer in the documentation
24 //     and/or other materials provided with the distribution.
25 //
26 //   * The name of Intel Corporation may not be used to endorse or promote products
27 //     derived from this software without specific prior written permission.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 //M*/
41
42 #ifndef _CV_VM_H_
43 #define _CV_VM_H_
44
45 /*----------------------- Internal ViewMorphing Functions ------------------------------*/
46
47 /*======================================================================================*/
48
49 typedef struct CvMatrix4
50 {
51     float m[4][4];
52 }
53 CvMatrix4;
54
55
56 /* Scanline section. Find coordinates by fundamental matrix */
57
58 /* Epsilon and real zero */
59 #define EPSILON             1.e-4
60 //#define REAL_ZERO(x)        ( (x) < EPSILON && (x) > -EPSILON)
61 #define REAL_ZERO(x) ( (x) < 1e-8 && (x) > -1e-8)
62
63 #define SIGN(x)                         ( (x)<0 ? -1:((x)>0?1:0 ) )
64
65 CvStatus  icvMakeScanlinesLengths( int*        scanlines,
66                                     int         numlines,
67                                     int*        lens);
68
69 /*=============================== PreWarp section ======================================*/
70
71 CvStatus  icvFindRunsInOneImage(
72                                 int     numLines,       /* number of scanlines          */
73                                 uchar*  prewarp,        /* prewarp image                        */
74                                 int*    line_lens,      /* line lengths in pixels       */
75                                 int*    runs,           /* result runs                          */
76                                 int*    num_runs);
77
78 /*================================ Morphing section ====================================*/
79
80 CvStatus  icvMorphEpilines8uC3(    uchar*  first_pix, /* raster epiline from the first image       */
81                                     uchar*  second_pix, /* raster epiline from the second image      */
82                                     uchar*  dst_pix,    /* raster epiline from the destination image */
83                                                         /* (it's an output parameter)                */
84                                     float   alpha,      /* relative position of camera               */
85                                     int*    first,      /* first sequence of runs                    */
86                                     int     first_runs, /* it's length                               */
87                                     int*    second,     /* second sequence of runs                   */
88                                     int     second_runs,
89                                     int*    first_corr, /* correspond information for the 1st seq    */
90                                     int*    second_corr,
91                                     int     dst_len);   /* correspond information for the 2nd seq    */
92
93 /*========================== Dynamic correspond section ================================*/
94
95 CvStatus  icvDynamicCorrespond(   int*  first,         /* first sequence of runs           */
96                                                          /* s0|w0|s1|w1|...|s(n-1)|w(n-1)|sn */
97                                     int   first_runs,    /* number of runs                   */
98                                     int*  second,        /* second sequence of runs          */
99                                     int   second_runs,
100                                     int*  first_corr,    /* s0'|e0'|s1'|e1'|...              */
101                                     int*  second_corr );
102
103 /*============================= PostWarp Functions =====================================*/
104
105 CvStatus  icvFetchLine8uC3R(
106                                 uchar*   src,  int   src_step,
107                                 uchar*   dst,  int*  dst_num,
108                                 CvSize  src_size,
109                                 CvPoint start,
110                                 CvPoint end );
111
112 CvStatus  icvDrawLine8uC3R(
113                                 uchar*   src,  int  src_num,
114                                 uchar*   dst,  int  dst_step,
115                                 CvSize  dst_size,
116                                 CvPoint start,
117                                 CvPoint end );
118
119
120 /*============================== Fundamental Matrix Functions ==========================*/
121 CvStatus  icvPoint7(  int*        points1,
122                         int*        points2,
123                         double*     F,
124                         int*        amount
125                         );
126
127 CvStatus  icvCubic(      double a2, double a1,
128                             double a0, double* squares );
129
130 double icvDet( double* M );
131 double   icvMinor( double* M, int x, int y );
132
133 int
134 icvGaussMxN( double *A, double *B, int M, int N, double **solutions );
135
136 CvStatus
137 icvGetCoef( double *f1, double *f2, double *a2, double *a1, double *a0 );
138
139 /*================================= Scanlines Functions ================================*/
140
141 CvStatus  icvGetCoefficient(  CvMatrix3*     matrix,
142                                 CvSize         imgSize,
143                                 int*            scanlines_1,
144                                 int*            scanlines_2,
145                                 int*            numlines);
146
147 CvStatus  icvGetCoefficientDefault(   CvMatrix3*     matrix,
148                                         CvSize         imgSize,
149                                         int*            scanlines_1,
150                                         int*            scanlines_2,
151                                         int*            numlines);
152
153 CvStatus  icvGetCoefficientStereo(    CvMatrix3*     matrix,
154                                         CvSize         imgSize,
155                                         float*          l_epipole,
156                                         float*          r_epipole,
157                                         int*            scanlines_1,
158                                         int*            scanlines_2,
159                                         int*            numlines
160                                     );
161
162 CvStatus  icvGetCoefficientOrto(  CvMatrix3*     matrix,
163                                     CvSize         imgSize,
164                                     int*            scanlines_1,
165                                     int*            scanlines_2,
166                                     int*            numlines);
167
168
169 CvStatus  icvGetCrossEpilineFrame(    CvSize     imgSize,
170                                         float*      epiline,
171                                         int*        x1,
172                                         int*        y1,
173                                         int*        x2,
174                                         int*        y2
175                                     );
176
177 CvStatus  icvBuildScanlineLeftStereo(
178                                         CvSize         imgSize,
179                                         CvMatrix3*     matrix,
180                                         float*          l_epipole,
181                                         float*          l_angle,
182                                         float           l_radius,
183                                         int*            scanlines_1,
184                                         int*            scanlines_2,
185                                         int*            numlines);
186
187 CvStatus  icvBuildScanlineRightStereo(
188                                         CvSize         imgSize,
189                                         CvMatrix3*     matrix,
190                                         float*          r_epipole,
191                                         float*          r_angle,
192                                         float           r_radius,
193                                         int*            scanlines_1,
194                                         int*            scanlines_2,
195                                         int*            numlines);
196
197 CvStatus  icvGetStartEnd1(
198                                     CvMatrix3*     matrix,
199                                     CvSize         imgSize,
200                                     float*          l_start_end,
201                                     float*          r_start_end );
202
203 CvStatus  icvGetStartEnd2(
204                                     CvMatrix3*     matrix,
205                                     CvSize         imgSize,
206                                     float*          l_start_end,
207                                     float*          r_start_end );
208
209 CvStatus  icvGetStartEnd3(
210                                     CvMatrix3*     matrix,
211                                     CvSize         imgSize,
212                                     float*          l_start_end,
213                                     float*          r_start_end );
214
215 CvStatus  icvGetStartEnd4(
216                                     CvMatrix3*     matrix,
217                                     CvSize         imgSize,
218                                     float*          l_start_end,
219                                     float*          r_start_end );
220
221 CvStatus  icvBuildScanlineLeft(
222                                     CvMatrix3*     matrix,
223                                     CvSize         imgSize,
224                                     int*            scanlines_1,
225                                     int*            scanlines_2,
226                                     float*          l_start_end,
227                                     int*            numlines
228                                     );
229
230 CvStatus  icvBuildScanlineRight(
231                                     CvMatrix3*     matrix,
232                                     CvSize         imgSize,
233                                     int*            scanlines_1,
234                                     int*            scanlines_2,
235                                     float*          r_start_end,
236                                     int*            numlines
237                                     );
238
239
240 /*=================================== LMedS Functions ==================================*/
241 CvStatus  icvLMedS7(
242                         int*            points1,
243                         int*            points2,
244                         CvMatrix3*     matrix);
245
246
247 CvStatus  icvLMedS(   int*    points1,
248                         int*    points2,
249                         int     numPoints,
250                         CvMatrix3* fundamentalMatrix );
251
252
253 /*
254 CvStatus  icvFindFundamentalMatrix(
255                                     int*            points1,
256                                     int*            points2,
257                                     int             numpoints,
258                                     int             method,
259                                     CvMatrix3*      matrix);
260 */
261 void   icvChoose7(      int*    ml,     int* mr,
262                         int     num,    int* ml7,
263                         int*   mr7 );
264
265 double icvMedian(       int* ml, int* mr,
266                     int num, double* F );
267
268 int icvBoltingPoints( int* ml,      int* mr,
269                         int num,        double* F,
270                         double Mj,      int* *new_ml,
271                         int* *new_mr,   int* new_num);
272
273 CvStatus  icvPoints8( int* ml, int* mr,
274                         int num, double* F );
275
276 CvStatus  icvRank2Constraint( double* F );
277
278 CvStatus  icvSort( double* array, int length );
279
280 double icvAnalyticPoints8(      double* A,
281                                             int num, double* F );
282
283 int icvSingularValueDecomposition(      int             M,
284                                         int             N,
285                                         double* A,
286                                         double* W,
287                                         int             get_U,
288                                         double* U,
289                                         int             get_V,
290                                         double* V
291                                                  );
292
293
294 /*======================================================================================*/
295 #endif/*_CV_VM_H_*/