1 /*M///////////////////////////////////////////////////////////////////////////////////////
\r
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
\r
5 // By downloading, copying, installing or using the software you agree to this license.
\r
6 // If you do not agree to this license, do not download, install,
\r
7 // copy or use the software.
\r
10 // License Agreement
\r
11 // For Open Source Computer Vision Library
\r
13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
\r
14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
\r
15 // Third party copyrights are property of their respective owners.
\r
17 // Redistribution and use in source and binary forms, with or without modification,
\r
18 // are permitted provided that the following conditions are met:
\r
20 // * Redistribution's of source code must retain the above copyright notice,
\r
21 // this list of conditions and the following disclaimer.
\r
23 // * Redistribution's in binary form must reproduce the above copyright notice,
\r
24 // this list of conditions and the following disclaimer in the documentation
\r
25 // and/or other materials provided with the distribution.
\r
27 // * The name of the copyright holders may not be used to endorse or promote products
\r
28 // derived from this software without specific prior written permission.
\r
30 // This software is provided by the copyright holders and contributors "as is" and
\r
31 // any express or implied warranties, including, but not limited to, the implied
\r
32 // warranties of merchantability and fitness for a particular purpose are disclaimed.
\r
33 // In no event shall the Intel Corporation or contributors be liable for any direct,
\r
34 // indirect, incidental, special, exemplary, or consequential damages
\r
35 // (including, but not limited to, procurement of substitute goods or services;
\r
36 // loss of use, data, or profits; or business interruption) however caused
\r
37 // and on any theory of liability, whether in contract, strict liability,
\r
38 // or tort (including negligence or otherwise) arising in any way out of
\r
39 // the use of this software, even if advised of the possibility of such damage.
\r
51 enum { BORDER_REPLICATE=IPL_BORDER_REPLICATE, BORDER_CONSTANT=IPL_BORDER_CONSTANT,
\r
52 BORDER_REFLECT=IPL_BORDER_REFLECT, BORDER_REFLECT_101=IPL_BORDER_REFLECT_101,
\r
53 BORDER_REFLECT101=BORDER_REFLECT_101, BORDER_WRAP=IPL_BORDER_WRAP,
\r
54 BORDER_TRANSPARENT, BORDER_DEFAULT=BORDER_REFLECT_101, BORDER_ISOLATED=16 };
\r
56 CV_EXPORTS int borderInterpolate( int p, int len, int borderType );
\r
58 struct CV_EXPORTS BaseRowFilter
\r
61 virtual ~BaseRowFilter();
\r
62 virtual void operator()(const uchar* src, uchar* dst,
\r
63 int width, int cn) = 0;
\r
68 struct CV_EXPORTS BaseColumnFilter
\r
71 virtual ~BaseColumnFilter();
\r
72 virtual void operator()(const uchar** src, uchar* dst, int dststep,
\r
73 int dstcount, int width) = 0;
\r
74 virtual void reset();
\r
79 struct CV_EXPORTS BaseFilter
\r
82 virtual ~BaseFilter();
\r
83 virtual void operator()(const uchar** src, uchar* dst, int dststep,
\r
84 int dstcount, int width, int cn) = 0;
\r
85 virtual void reset();
\r
91 struct CV_EXPORTS FilterEngine
\r
94 FilterEngine(const Ptr<BaseFilter>& _filter2D,
\r
95 const Ptr<BaseRowFilter>& _rowFilter,
\r
96 const Ptr<BaseColumnFilter>& _columnFilter,
\r
97 int srcType, int dstType, int bufType,
\r
98 int _rowBorderType=BORDER_REPLICATE,
\r
99 int _columnBorderType=-1,
\r
100 const Scalar& _borderValue=Scalar());
\r
101 virtual ~FilterEngine();
\r
102 void init(const Ptr<BaseFilter>& _filter2D,
\r
103 const Ptr<BaseRowFilter>& _rowFilter,
\r
104 const Ptr<BaseColumnFilter>& _columnFilter,
\r
105 int srcType, int dstType, int bufType,
\r
106 int _rowBorderType=BORDER_REPLICATE, int _columnBorderType=-1,
\r
107 const Scalar& _borderValue=Scalar());
\r
108 virtual int start(Size wholeSize, Rect roi, int maxBufRows=-1);
\r
109 virtual int start(const Mat& src, const Rect& srcRoi=Rect(0,0,-1,-1),
\r
110 bool isolated=false, int maxBufRows=-1);
\r
111 virtual int proceed(const uchar* src, int srcStep, int srcCount,
\r
112 uchar* dst, int dstStep);
\r
113 virtual void apply( const Mat& src, Mat& dst,
\r
114 const Rect& srcRoi=Rect(0,0,-1,-1),
\r
115 Point dstOfs=Point(0,0),
\r
116 bool isolated=false);
\r
117 bool isSeparable() const { return filter2D.obj == 0; }
\r
118 int remainingInputRows() const;
\r
119 int remainingOutputRows() const;
\r
121 int srcType, dstType, bufType;
\r
128 int rowBorderType, columnBorderType;
\r
129 Vector<int> borderTab;
\r
130 int borderElemSize;
\r
131 Vector<uchar> ringBuf;
\r
132 Vector<uchar> srcRow;
\r
133 Vector<uchar> constBorderValue;
\r
134 Vector<uchar> constBorderRow;
\r
135 int bufStep, startY, startY0, endY, rowCount, dstY;
\r
136 Vector<uchar*> rows;
\r
138 Ptr<BaseFilter> filter2D;
\r
139 Ptr<BaseRowFilter> rowFilter;
\r
140 Ptr<BaseColumnFilter> columnFilter;
\r
143 enum { KERNEL_GENERAL=0, KERNEL_SYMMETRICAL=1, KERNEL_ASYMMETRICAL=2,
\r
144 KERNEL_SMOOTH=4, KERNEL_INTEGER=8 };
\r
146 CV_EXPORTS int getKernelType(const Mat& kernel, Point anchor);
\r
148 CV_EXPORTS Ptr<BaseRowFilter> getLinearRowFilter(int srcType, int bufType,
\r
149 const Mat& kernel, int anchor,
\r
152 CV_EXPORTS Ptr<BaseColumnFilter> getLinearColumnFilter(int bufType, int dstType,
\r
153 const Mat& kernel, int anchor,
\r
154 int symmetryType, double delta=0,
\r
157 CV_EXPORTS Ptr<BaseFilter> getLinearFilter(int srcType, int dstType,
\r
159 Point anchor=Point(-1,-1),
\r
160 double delta=0, int bits=0);
\r
162 CV_EXPORTS Ptr<FilterEngine> createSeparableLinearFilter(int srcType, int dstType,
\r
163 const Mat& rowKernel, const Mat& columnKernel,
\r
164 Point _anchor=Point(-1,-1), double delta=0,
\r
165 int _rowBorderType=BORDER_DEFAULT,
\r
166 int _columnBorderType=-1,
\r
167 const Scalar& _borderValue=Scalar());
\r
169 CV_EXPORTS Ptr<FilterEngine> createLinearFilter(int srcType, int dstType,
\r
170 const Mat& kernel, Point _anchor=Point(-1,-1),
\r
171 double delta=0, int _rowBorderType=BORDER_DEFAULT,
\r
172 int _columnBorderType=-1, const Scalar& _borderValue=Scalar());
\r
174 CV_EXPORTS Mat getGaussianKernel( int ksize, double sigma, int ktype=CV_64F );
\r
176 CV_EXPORTS Ptr<FilterEngine> createGaussianFilter( int type, Size ksize,
\r
177 double sigma1, double sigma2=0,
\r
178 int borderType=BORDER_DEFAULT);
\r
180 CV_EXPORTS void getDerivKernels( Mat& kx, Mat& ky, int dx, int dy, int ksize,
\r
181 bool normalize=false, int ktype=CV_32F );
\r
183 CV_EXPORTS Ptr<FilterEngine> createDerivFilter( int srcType, int dstType,
\r
184 int dx, int dy, int ksize,
\r
185 int borderType=BORDER_DEFAULT );
\r
187 CV_EXPORTS Ptr<BaseRowFilter> getRowSumFilter(int srcType, int sumType,
\r
188 int ksize, int anchor=-1);
\r
189 CV_EXPORTS Ptr<BaseColumnFilter> getColumnSumFilter(int sumType, int dstType,
\r
190 int ksize, int anchor=-1,
\r
192 CV_EXPORTS Ptr<FilterEngine> createBoxFilter( int srcType, int dstType, Size ksize,
\r
193 Point anchor=Point(-1,-1),
\r
194 bool normalize=true,
\r
195 int borderType=BORDER_DEFAULT);
\r
197 enum { MORPH_ERODE=0, MORPH_DILATE=1, MORPH_OPEN=2, MORPH_CLOSE=3,
\r
198 MORPH_GRADIENT=4, MORPH_TOPHAT=5, MORPH_BLACKHAT=6 };
\r
200 CV_EXPORTS Ptr<BaseRowFilter> getMorphologyRowFilter(int op, int type, int ksize, int anchor=-1);
\r
201 CV_EXPORTS Ptr<BaseColumnFilter> getMorphologyColumnFilter(int op, int type, int ksize, int anchor=-1);
\r
202 CV_EXPORTS Ptr<BaseFilter> getMorphologyFilter(int op, int type, const Mat& kernel,
\r
203 Point anchor=Point(-1,-1));
\r
205 static inline Scalar morphologyDefaultBorderValue() { return Scalar::all(DBL_MAX); }
\r
207 CV_EXPORTS Ptr<FilterEngine> createMorphologyFilter(int op, int type, const Mat& kernel,
\r
208 Point anchor=Point(-1,-1), int _rowBorderType=BORDER_CONSTANT,
\r
209 int _columnBorderType=-1,
\r
210 const Scalar& _borderValue=morphologyDefaultBorderValue());
\r
212 enum { MORPH_RECT=0, MORPH_CROSS=1, MORPH_ELLIPSE=2 };
\r
213 CV_EXPORTS Mat getStructuringElement(int shape, Size ksize, Point anchor=Point(-1,-1));
\r
215 CV_EXPORTS void copyMakeBorder( const Mat& src, Mat& dst,
\r
216 int top, int bottom, int left, int right,
\r
219 CV_EXPORTS void medianBlur( const Mat& src, Mat& dst, int ksize );
\r
220 CV_EXPORTS void GaussianBlur( const Mat& src, Mat& dst, Size ksize,
\r
221 double sigma1, double sigma2=0,
\r
222 int borderType=BORDER_DEFAULT );
\r
223 CV_EXPORTS void bilateralFilter( const Mat& src, Mat& dst, int d,
\r
224 double sigmaColor, double sigmaSpace,
\r
225 int borderType=BORDER_DEFAULT );
\r
226 CV_EXPORTS void boxFilter( const Mat& src, Mat& dst, int ddepth,
\r
227 Size ksize, Point anchor=Point(-1,-1),
\r
228 bool normalize=true,
\r
229 int borderType=BORDER_DEFAULT );
\r
230 static inline void blur( const Mat& src, Mat& dst,
\r
231 Size ksize, Point anchor=Point(-1,-1),
\r
232 int borderType=BORDER_DEFAULT )
\r
234 boxFilter( src, dst, -1, ksize, anchor, true, borderType );
\r
237 CV_EXPORTS void filter2D( const Mat& src, Mat& dst, int ddepth,
\r
238 const Mat& kernel, Point anchor=Point(-1,-1),
\r
239 double delta=0, int borderType=BORDER_DEFAULT );
\r
241 CV_EXPORTS void sepFilter2D( const Mat& src, Mat& dst, int ddepth,
\r
242 const Mat& kernelX, const Mat& kernelY,
\r
243 Point anchor=Point(-1,-1),
\r
244 double delta=0, int borderType=BORDER_DEFAULT );
\r
246 CV_EXPORTS void Sobel( const Mat& src, Mat& dst, int ddepth,
\r
247 int dx, int dy, int ksize=3,
\r
248 double scale=1, double delta=0,
\r
249 int borderType=BORDER_DEFAULT );
\r
251 CV_EXPORTS void Scharr( const Mat& src, Mat& dst, int ddepth,
\r
252 int dx, int dy, double scale=1, double delta=0,
\r
253 int borderType=BORDER_DEFAULT );
\r
255 CV_EXPORTS void Laplacian( const Mat& src, Mat& dst, int ddepth,
\r
256 int ksize=1, double scale=1, double delta=0,
\r
257 int borderType=BORDER_DEFAULT );
\r
259 CV_EXPORTS void erode( const Mat& src, Mat& dst, const Mat& kernel,
\r
260 Point anchor=Point(-1,-1), int iterations=1,
\r
261 int borderType=BORDER_CONSTANT,
\r
262 const Scalar& borderValue=morphologyDefaultBorderValue() );
\r
263 CV_EXPORTS void dilate( const Mat& src, Mat& dst, const Mat& kernel,
\r
264 Point anchor=Point(-1,-1), int iterations=1,
\r
265 int borderType=BORDER_CONSTANT,
\r
266 const Scalar& borderValue=morphologyDefaultBorderValue() );
\r
267 CV_EXPORTS void morphologyEx( const Mat& src, Mat& dst, int op, const Mat& kernel,
\r
268 Point anchor=Point(-1,-1), int iterations=1,
\r
269 int borderType=BORDER_CONSTANT,
\r
270 const Scalar& borderValue=morphologyDefaultBorderValue() );
\r
272 enum { INTER_NEAREST=0, INTER_LINEAR=1, INTER_CUBIC=2, INTER_AREA=3,
\r
273 INTER_LANCZOS4=4, INTER_MAX=7, WARP_INVERSE_MAP=16 };
\r
275 CV_EXPORTS void resize( const Mat& src, Mat& dst,
\r
276 Size dsize=Size(), double fx=0, double fy=0,
\r
277 int interpolation=INTER_LINEAR );
\r
279 CV_EXPORTS void warpAffine( const Mat& src, Mat& dst,
\r
280 const Mat& M, Size dsize,
\r
281 int flags=INTER_LINEAR,
\r
282 int borderMode=BORDER_CONSTANT,
\r
283 const Scalar& borderValue=Scalar());
\r
284 CV_EXPORTS void warpPerspective( const Mat& src, Mat& dst,
\r
285 const Mat& M, Size dsize,
\r
286 int flags=INTER_LINEAR,
\r
287 int borderMode=BORDER_CONSTANT,
\r
288 const Scalar& borderValue=Scalar());
\r
290 CV_EXPORTS void remap( const Mat& src, Mat& dst, const Mat& map1, const Mat& map2,
\r
291 int interpolation, int borderMode=BORDER_CONSTANT,
\r
292 const Scalar& borderValue=Scalar());
\r
294 CV_EXPORTS void convertMaps( const Mat& map1, const Mat& map2, Mat& dstmap1, Mat& dstmap2,
\r
295 int dstmap1type, bool nninterpolation=false );
\r
297 CV_EXPORTS Mat getRotationMatrix2D( Point2f center, double angle, double scale );
\r
298 CV_EXPORTS Mat getPerspectiveTransform( const Point2f src[], const Point2f dst[] );
\r
299 CV_EXPORTS Mat getAffineTransform( const Point2f src[], const Point2f dst[] );
\r
301 CV_EXPORTS void integral( const Mat& src, Mat& sum, int sdepth=-1 );
\r
302 CV_EXPORTS void integral( const Mat& src, Mat& sum, Mat& sqsum, int sdepth=-1 );
\r
303 CV_EXPORTS void integral( const Mat& src, Mat& sum, Mat& sqsum, Mat& tilted, int sdepth=-1 );
\r
305 CV_EXPORTS void accumulate( const Mat& src, Mat& dst, const Mat& mask=Mat() );
\r
306 CV_EXPORTS void accumulateSquare( const Mat& src, Mat& dst, const Mat& mask=Mat() );
\r
307 CV_EXPORTS void accumulateProduct( const Mat& src1, const Mat& src2,
\r
308 Mat& dst, const Mat& mask=Mat() );
\r
309 CV_EXPORTS void accumulateWeighted( const Mat& src, Mat& dst,
\r
310 double alpha, const Mat& mask=Mat() );
\r
312 enum { THRESH_BINARY=0, THRESH_BINARY_INV=1, THRESH_TRUNC=2, THRESH_TOZERO=3,
\r
313 THRESH_TOZERO_INV=4, THRESH_MASK=7, THRESH_OTSU=8 };
\r
315 CV_EXPORTS double threshold( const Mat& src, Mat& dst, double thresh, double maxval, int type );
\r
317 enum { ADAPTIVE_THRESH_MEAN_C=0, ADAPTIVE_THRESH_GAUSSIAN_C=1 };
\r
319 CV_EXPORTS void adaptiveThreshold( const Mat& src, Mat& dst, double maxValue,
\r
320 int adaptiveMethod, int thresholdType,
\r
321 int blockSize, double C );
\r
325 //////////////////////////////////////////////////////////////////////////////////////////
\r
327 struct CV_EXPORTS CvLevMarq
\r
330 CvLevMarq( int nparams, int nerrs, CvTermCriteria criteria=
\r
331 cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,DBL_EPSILON),
\r
332 bool completeSymmFlag=false );
\r
334 void init( int nparams, int nerrs, CvTermCriteria criteria=
\r
335 cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,DBL_EPSILON),
\r
336 bool completeSymmFlag=false );
\r
337 bool update( const CvMat*& param, CvMat*& J, CvMat*& err );
\r
338 bool updateAlt( const CvMat*& param, CvMat*& JtJ, CvMat*& JtErr, double*& errNorm );
\r
342 enum { DONE=0, STARTED=1, CALC_J=2, CHECK_ERR=3 };
\r
354 double prevErrNorm, errNorm;
\r
356 CvTermCriteria criteria;
\r
359 bool completeSymmFlag;
\r
363 // 2009-01-12, Xavier Delacour <xavier.delacour@gmail.com>
\r
369 struct CvLSHOperations {
\r
370 virtual ~CvLSHOperations() {}
\r
372 virtual int vector_add(const void* data) = 0;
\r
373 virtual void vector_remove(int i) = 0;
\r
374 virtual const void* vector_lookup(int i) = 0;
\r
375 virtual void vector_reserve(int n) = 0;
\r
376 virtual unsigned int vector_count() = 0;
\r
378 virtual void hash_insert(lsh_hash h, int l, int i) = 0;
\r
379 virtual void hash_remove(lsh_hash h, int l, int i) = 0;
\r
380 virtual int hash_lookup(lsh_hash h, int l, int* ret_i, int ret_i_max) = 0;
\r
384 #endif /* __cplusplus */
\r
386 #endif /* _CV_HPP_ */
\r