1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
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.
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15 // Third party copyrights are property of their respective owners.
17 // Redistribution and use in source and binary forms, with or without modification,
18 // are permitted provided that the following conditions are met:
20 // * Redistribution's of source code must retain the above copyright notice,
21 // this list of conditions and the following disclaimer.
23 // * Redistribution's in binary form must reproduce the above copyright notice,
24 // this list of conditions and the following disclaimer in the documentation
25 // and/or other materials provided with the distribution.
27 // * The name of the copyright holders may not be used to endorse or promote products
28 // derived from this software without specific prior written permission.
30 // This software is provided by the copyright holders and contributors "as is" and
31 // any express or implied warranties, including, but not limited to, the implied
32 // warranties of merchantability and fitness for a particular purpose are disclaimed.
33 // In no event shall the Intel Corporation or contributors be liable for any direct,
34 // indirect, incidental, special, exemplary, or consequential damages
35 // (including, but not limited to, procurement of substitute goods or services;
36 // loss of use, data, or profits; or business interruption) however caused
37 // and on any theory of liability, whether in contract, strict liability,
38 // or tort (including negligence or otherwise) arising in any way out of
39 // the use of this software, even if advised of the possibility of such damage.
43 #ifndef __OPENCV_IMGPROC_HPP__
44 #define __OPENCV_IMGPROC_HPP__
46 #include "opencv2/core.hpp"
49 Namespace where all the C++ OpenCV functionality resides
54 //! type of morphological operation
55 enum { MORPH_ERODE = 0,
64 //! shape of the structuring element
65 enum { MORPH_RECT = 0,
70 //! interpolation algorithm
71 enum { INTER_NEAREST = 0, //!< nearest neighbor interpolation
72 INTER_LINEAR = 1, //!< bilinear interpolation
73 INTER_CUBIC = 2, //!< bicubic interpolation
74 INTER_AREA = 3, //!< area-based (or super) interpolation
75 INTER_LANCZOS4 = 4, //!< Lanczos interpolation over 8x8 neighborhood
77 INTER_MAX = 7, //!< mask for interpolation codes
78 WARP_FILL_OUTLIERS = 8,
82 enum { INTER_BITS = 5,
83 INTER_BITS2 = INTER_BITS * 2,
84 INTER_TAB_SIZE = 1 << INTER_BITS,
85 INTER_TAB_SIZE2 = INTER_TAB_SIZE * INTER_TAB_SIZE
88 //! Distance types for Distance Transform and M-estimators
89 enum { DIST_USER = -1, // User defined distance
90 DIST_L1 = 1, // distance = |x1-x2| + |y1-y2|
91 DIST_L2 = 2, // the simple euclidean distance
92 DIST_C = 3, // distance = max(|x1-x2|,|y1-y2|)
93 DIST_L12 = 4, // L1-L2 metric: distance = 2(sqrt(1+x*x/2) - 1))
94 DIST_FAIR = 5, // distance = c^2(|x|/c-log(1+|x|/c)), c = 1.3998
95 DIST_WELSCH = 6, // distance = c^2/2(1-exp(-(x/c)^2)), c = 2.9846
96 DIST_HUBER = 7 // distance = |x|<c ? x^2/2 : c(|x|-c/2), c=1.345
99 //! Mask size for distance transform
100 enum { DIST_MASK_3 = 3,
102 DIST_MASK_PRECISE = 0
105 //! type of the threshold operation
106 enum { THRESH_BINARY = 0, // value = value > threshold ? max_value : 0
107 THRESH_BINARY_INV = 1, // value = value > threshold ? 0 : max_value
108 THRESH_TRUNC = 2, // value = value > threshold ? threshold : value
109 THRESH_TOZERO = 3, // value = value > threshold ? value : 0
110 THRESH_TOZERO_INV = 4, // value = value > threshold ? 0 : value
112 THRESH_OTSU = 8, // use Otsu algorithm to choose the optimal threshold value
113 THRESH_TRIANGLE = 16 // use Triangle algorithm to choose the optimal threshold value
116 //! adaptive threshold algorithm
117 enum { ADAPTIVE_THRESH_MEAN_C = 0,
118 ADAPTIVE_THRESH_GAUSSIAN_C = 1
121 enum { PROJ_SPHERICAL_ORTHO = 0,
122 PROJ_SPHERICAL_EQRECT = 1
125 //! class of the pixel in GrabCut algorithm
126 enum { GC_BGD = 0, //!< background
127 GC_FGD = 1, //!< foreground
128 GC_PR_BGD = 2, //!< most probably background
129 GC_PR_FGD = 3 //!< most probably foreground
132 //! GrabCut algorithm flags
133 enum { GC_INIT_WITH_RECT = 0,
134 GC_INIT_WITH_MASK = 1,
138 //! distanceTransform algorithm flags
139 enum { DIST_LABEL_CCOMP = 0,
143 //! floodfill algorithm flags
144 enum { FLOODFILL_FIXED_RANGE = 1 << 16,
145 FLOODFILL_MASK_ONLY = 1 << 17
148 //! type of the template matching operation
149 enum { TM_SQDIFF = 0,
150 TM_SQDIFF_NORMED = 1,
157 //! connected components algorithm output formats
158 enum { CC_STAT_LEFT = 0,
166 //! mode of the contour retrieval algorithm
167 enum { RETR_EXTERNAL = 0, //!< retrieve only the most external (top-level) contours
168 RETR_LIST = 1, //!< retrieve all the contours without any hierarchical information
169 RETR_CCOMP = 2, //!< retrieve the connected components (that can possibly be nested)
170 RETR_TREE = 3, //!< retrieve all the contours and the whole hierarchy
174 //! the contour approximation algorithm
175 enum { CHAIN_APPROX_NONE = 1,
176 CHAIN_APPROX_SIMPLE = 2,
177 CHAIN_APPROX_TC89_L1 = 3,
178 CHAIN_APPROX_TC89_KCOS = 4
181 //! Variants of a Hough transform
182 enum { HOUGH_STANDARD = 0,
183 HOUGH_PROBABILISTIC = 1,
184 HOUGH_MULTI_SCALE = 2,
188 //! Variants of Line Segment Detector
189 enum { LSD_REFINE_NONE = 0,
194 //! Histogram comparison methods
195 enum { HISTCMP_CORREL = 0,
197 HISTCMP_INTERSECT = 2,
198 HISTCMP_BHATTACHARYYA = 3,
199 HISTCMP_HELLINGER = HISTCMP_BHATTACHARYYA,
200 HISTCMP_CHISQR_ALT = 4,
204 //! the color conversion code
205 enum { COLOR_BGR2BGRA = 0,
206 COLOR_RGB2RGBA = COLOR_BGR2BGRA,
209 COLOR_RGBA2RGB = COLOR_BGRA2BGR,
212 COLOR_RGB2BGRA = COLOR_BGR2RGBA,
215 COLOR_BGRA2RGB = COLOR_RGBA2BGR,
218 COLOR_RGB2BGR = COLOR_BGR2RGB,
221 COLOR_RGBA2BGRA = COLOR_BGRA2RGBA,
226 COLOR_GRAY2RGB = COLOR_GRAY2BGR,
228 COLOR_GRAY2RGBA = COLOR_GRAY2BGRA,
229 COLOR_BGRA2GRAY = 10,
230 COLOR_RGBA2GRAY = 11,
232 COLOR_BGR2BGR565 = 12,
233 COLOR_RGB2BGR565 = 13,
234 COLOR_BGR5652BGR = 14,
235 COLOR_BGR5652RGB = 15,
236 COLOR_BGRA2BGR565 = 16,
237 COLOR_RGBA2BGR565 = 17,
238 COLOR_BGR5652BGRA = 18,
239 COLOR_BGR5652RGBA = 19,
241 COLOR_GRAY2BGR565 = 20,
242 COLOR_BGR5652GRAY = 21,
244 COLOR_BGR2BGR555 = 22,
245 COLOR_RGB2BGR555 = 23,
246 COLOR_BGR5552BGR = 24,
247 COLOR_BGR5552RGB = 25,
248 COLOR_BGRA2BGR555 = 26,
249 COLOR_RGBA2BGR555 = 27,
250 COLOR_BGR5552BGRA = 28,
251 COLOR_BGR5552RGBA = 29,
253 COLOR_GRAY2BGR555 = 30,
254 COLOR_BGR5552GRAY = 31,
261 COLOR_BGR2YCrCb = 36,
262 COLOR_RGB2YCrCb = 37,
263 COLOR_YCrCb2BGR = 38,
264 COLOR_YCrCb2RGB = 39,
287 COLOR_BGR2HSV_FULL = 66,
288 COLOR_RGB2HSV_FULL = 67,
289 COLOR_BGR2HLS_FULL = 68,
290 COLOR_RGB2HLS_FULL = 69,
292 COLOR_HSV2BGR_FULL = 70,
293 COLOR_HSV2RGB_FULL = 71,
294 COLOR_HLS2BGR_FULL = 72,
295 COLOR_HLS2RGB_FULL = 73,
312 // YUV 4:2:0 family to RGB
313 COLOR_YUV2RGB_NV12 = 90,
314 COLOR_YUV2BGR_NV12 = 91,
315 COLOR_YUV2RGB_NV21 = 92,
316 COLOR_YUV2BGR_NV21 = 93,
317 COLOR_YUV420sp2RGB = COLOR_YUV2RGB_NV21,
318 COLOR_YUV420sp2BGR = COLOR_YUV2BGR_NV21,
320 COLOR_YUV2RGBA_NV12 = 94,
321 COLOR_YUV2BGRA_NV12 = 95,
322 COLOR_YUV2RGBA_NV21 = 96,
323 COLOR_YUV2BGRA_NV21 = 97,
324 COLOR_YUV420sp2RGBA = COLOR_YUV2RGBA_NV21,
325 COLOR_YUV420sp2BGRA = COLOR_YUV2BGRA_NV21,
327 COLOR_YUV2RGB_YV12 = 98,
328 COLOR_YUV2BGR_YV12 = 99,
329 COLOR_YUV2RGB_IYUV = 100,
330 COLOR_YUV2BGR_IYUV = 101,
331 COLOR_YUV2RGB_I420 = COLOR_YUV2RGB_IYUV,
332 COLOR_YUV2BGR_I420 = COLOR_YUV2BGR_IYUV,
333 COLOR_YUV420p2RGB = COLOR_YUV2RGB_YV12,
334 COLOR_YUV420p2BGR = COLOR_YUV2BGR_YV12,
336 COLOR_YUV2RGBA_YV12 = 102,
337 COLOR_YUV2BGRA_YV12 = 103,
338 COLOR_YUV2RGBA_IYUV = 104,
339 COLOR_YUV2BGRA_IYUV = 105,
340 COLOR_YUV2RGBA_I420 = COLOR_YUV2RGBA_IYUV,
341 COLOR_YUV2BGRA_I420 = COLOR_YUV2BGRA_IYUV,
342 COLOR_YUV420p2RGBA = COLOR_YUV2RGBA_YV12,
343 COLOR_YUV420p2BGRA = COLOR_YUV2BGRA_YV12,
345 COLOR_YUV2GRAY_420 = 106,
346 COLOR_YUV2GRAY_NV21 = COLOR_YUV2GRAY_420,
347 COLOR_YUV2GRAY_NV12 = COLOR_YUV2GRAY_420,
348 COLOR_YUV2GRAY_YV12 = COLOR_YUV2GRAY_420,
349 COLOR_YUV2GRAY_IYUV = COLOR_YUV2GRAY_420,
350 COLOR_YUV2GRAY_I420 = COLOR_YUV2GRAY_420,
351 COLOR_YUV420sp2GRAY = COLOR_YUV2GRAY_420,
352 COLOR_YUV420p2GRAY = COLOR_YUV2GRAY_420,
354 // YUV 4:2:2 family to RGB
355 COLOR_YUV2RGB_UYVY = 107,
356 COLOR_YUV2BGR_UYVY = 108,
357 //COLOR_YUV2RGB_VYUY = 109,
358 //COLOR_YUV2BGR_VYUY = 110,
359 COLOR_YUV2RGB_Y422 = COLOR_YUV2RGB_UYVY,
360 COLOR_YUV2BGR_Y422 = COLOR_YUV2BGR_UYVY,
361 COLOR_YUV2RGB_UYNV = COLOR_YUV2RGB_UYVY,
362 COLOR_YUV2BGR_UYNV = COLOR_YUV2BGR_UYVY,
364 COLOR_YUV2RGBA_UYVY = 111,
365 COLOR_YUV2BGRA_UYVY = 112,
366 //COLOR_YUV2RGBA_VYUY = 113,
367 //COLOR_YUV2BGRA_VYUY = 114,
368 COLOR_YUV2RGBA_Y422 = COLOR_YUV2RGBA_UYVY,
369 COLOR_YUV2BGRA_Y422 = COLOR_YUV2BGRA_UYVY,
370 COLOR_YUV2RGBA_UYNV = COLOR_YUV2RGBA_UYVY,
371 COLOR_YUV2BGRA_UYNV = COLOR_YUV2BGRA_UYVY,
373 COLOR_YUV2RGB_YUY2 = 115,
374 COLOR_YUV2BGR_YUY2 = 116,
375 COLOR_YUV2RGB_YVYU = 117,
376 COLOR_YUV2BGR_YVYU = 118,
377 COLOR_YUV2RGB_YUYV = COLOR_YUV2RGB_YUY2,
378 COLOR_YUV2BGR_YUYV = COLOR_YUV2BGR_YUY2,
379 COLOR_YUV2RGB_YUNV = COLOR_YUV2RGB_YUY2,
380 COLOR_YUV2BGR_YUNV = COLOR_YUV2BGR_YUY2,
382 COLOR_YUV2RGBA_YUY2 = 119,
383 COLOR_YUV2BGRA_YUY2 = 120,
384 COLOR_YUV2RGBA_YVYU = 121,
385 COLOR_YUV2BGRA_YVYU = 122,
386 COLOR_YUV2RGBA_YUYV = COLOR_YUV2RGBA_YUY2,
387 COLOR_YUV2BGRA_YUYV = COLOR_YUV2BGRA_YUY2,
388 COLOR_YUV2RGBA_YUNV = COLOR_YUV2RGBA_YUY2,
389 COLOR_YUV2BGRA_YUNV = COLOR_YUV2BGRA_YUY2,
391 COLOR_YUV2GRAY_UYVY = 123,
392 COLOR_YUV2GRAY_YUY2 = 124,
393 //CV_YUV2GRAY_VYUY = CV_YUV2GRAY_UYVY,
394 COLOR_YUV2GRAY_Y422 = COLOR_YUV2GRAY_UYVY,
395 COLOR_YUV2GRAY_UYNV = COLOR_YUV2GRAY_UYVY,
396 COLOR_YUV2GRAY_YVYU = COLOR_YUV2GRAY_YUY2,
397 COLOR_YUV2GRAY_YUYV = COLOR_YUV2GRAY_YUY2,
398 COLOR_YUV2GRAY_YUNV = COLOR_YUV2GRAY_YUY2,
400 // alpha premultiplication
401 COLOR_RGBA2mRGBA = 125,
402 COLOR_mRGBA2RGBA = 126,
404 // RGB to YUV 4:2:0 family
405 COLOR_RGB2YUV_I420 = 127,
406 COLOR_BGR2YUV_I420 = 128,
407 COLOR_RGB2YUV_IYUV = COLOR_RGB2YUV_I420,
408 COLOR_BGR2YUV_IYUV = COLOR_BGR2YUV_I420,
410 COLOR_RGBA2YUV_I420 = 129,
411 COLOR_BGRA2YUV_I420 = 130,
412 COLOR_RGBA2YUV_IYUV = COLOR_RGBA2YUV_I420,
413 COLOR_BGRA2YUV_IYUV = COLOR_BGRA2YUV_I420,
414 COLOR_RGB2YUV_YV12 = 131,
415 COLOR_BGR2YUV_YV12 = 132,
416 COLOR_RGBA2YUV_YV12 = 133,
417 COLOR_BGRA2YUV_YV12 = 134,
420 COLOR_BayerBG2BGR = 46,
421 COLOR_BayerGB2BGR = 47,
422 COLOR_BayerRG2BGR = 48,
423 COLOR_BayerGR2BGR = 49,
425 COLOR_BayerBG2RGB = COLOR_BayerRG2BGR,
426 COLOR_BayerGB2RGB = COLOR_BayerGR2BGR,
427 COLOR_BayerRG2RGB = COLOR_BayerBG2BGR,
428 COLOR_BayerGR2RGB = COLOR_BayerGB2BGR,
430 COLOR_BayerBG2GRAY = 86,
431 COLOR_BayerGB2GRAY = 87,
432 COLOR_BayerRG2GRAY = 88,
433 COLOR_BayerGR2GRAY = 89,
435 // Demosaicing using Variable Number of Gradients
436 COLOR_BayerBG2BGR_VNG = 62,
437 COLOR_BayerGB2BGR_VNG = 63,
438 COLOR_BayerRG2BGR_VNG = 64,
439 COLOR_BayerGR2BGR_VNG = 65,
441 COLOR_BayerBG2RGB_VNG = COLOR_BayerRG2BGR_VNG,
442 COLOR_BayerGB2RGB_VNG = COLOR_BayerGR2BGR_VNG,
443 COLOR_BayerRG2RGB_VNG = COLOR_BayerBG2BGR_VNG,
444 COLOR_BayerGR2RGB_VNG = COLOR_BayerGB2BGR_VNG,
446 // Edge-Aware Demosaicing
447 COLOR_BayerBG2BGR_EA = 135,
448 COLOR_BayerGB2BGR_EA = 136,
449 COLOR_BayerRG2BGR_EA = 137,
450 COLOR_BayerGR2BGR_EA = 138,
452 COLOR_BayerBG2RGB_EA = COLOR_BayerRG2BGR_EA,
453 COLOR_BayerGB2RGB_EA = COLOR_BayerGR2BGR_EA,
454 COLOR_BayerRG2RGB_EA = COLOR_BayerBG2BGR_EA,
455 COLOR_BayerGR2RGB_EA = COLOR_BayerGB2BGR_EA,
458 COLOR_COLORCVT_MAX = 139
461 //! types of intersection between rectangles
462 enum { INTERSECT_NONE = 0,
463 INTERSECT_PARTIAL = 1,
467 //! finds arbitrary template in the grayscale image using Generalized Hough Transform
468 class CV_EXPORTS GeneralizedHough : public Algorithm
471 //! set template to search
472 virtual void setTemplate(InputArray templ, Point templCenter = Point(-1, -1)) = 0;
473 virtual void setTemplate(InputArray edges, InputArray dx, InputArray dy, Point templCenter = Point(-1, -1)) = 0;
475 //! find template on image
476 virtual void detect(InputArray image, OutputArray positions, OutputArray votes = noArray()) = 0;
477 virtual void detect(InputArray edges, InputArray dx, InputArray dy, OutputArray positions, OutputArray votes = noArray()) = 0;
479 //! Canny low threshold.
480 virtual void setCannyLowThresh(int cannyLowThresh) = 0;
481 virtual int getCannyLowThresh() const = 0;
483 //! Canny high threshold.
484 virtual void setCannyHighThresh(int cannyHighThresh) = 0;
485 virtual int getCannyHighThresh() const = 0;
487 //! Minimum distance between the centers of the detected objects.
488 virtual void setMinDist(double minDist) = 0;
489 virtual double getMinDist() const = 0;
491 //! Inverse ratio of the accumulator resolution to the image resolution.
492 virtual void setDp(double dp) = 0;
493 virtual double getDp() const = 0;
495 //! Maximal size of inner buffers.
496 virtual void setMaxBufferSize(int maxBufferSize) = 0;
497 virtual int getMaxBufferSize() const = 0;
500 //! Ballard, D.H. (1981). Generalizing the Hough transform to detect arbitrary shapes. Pattern Recognition 13 (2): 111-122.
501 //! Detects position only without traslation and rotation
502 class CV_EXPORTS GeneralizedHoughBallard : public GeneralizedHough
506 virtual void setLevels(int levels) = 0;
507 virtual int getLevels() const = 0;
509 //! The accumulator threshold for the template centers at the detection stage. The smaller it is, the more false positions may be detected.
510 virtual void setVotesThreshold(int votesThreshold) = 0;
511 virtual int getVotesThreshold() const = 0;
514 //! Guil, N., González-Linares, J.M. and Zapata, E.L. (1999). Bidimensional shape detection using an invariant approach. Pattern Recognition 32 (6): 1025-1038.
515 //! Detects position, traslation and rotation
516 class CV_EXPORTS GeneralizedHoughGuil : public GeneralizedHough
519 //! Angle difference in degrees between two points in feature.
520 virtual void setXi(double xi) = 0;
521 virtual double getXi() const = 0;
523 //! Feature table levels.
524 virtual void setLevels(int levels) = 0;
525 virtual int getLevels() const = 0;
527 //! Maximal difference between angles that treated as equal.
528 virtual void setAngleEpsilon(double angleEpsilon) = 0;
529 virtual double getAngleEpsilon() const = 0;
531 //! Minimal rotation angle to detect in degrees.
532 virtual void setMinAngle(double minAngle) = 0;
533 virtual double getMinAngle() const = 0;
535 //! Maximal rotation angle to detect in degrees.
536 virtual void setMaxAngle(double maxAngle) = 0;
537 virtual double getMaxAngle() const = 0;
539 //! Angle step in degrees.
540 virtual void setAngleStep(double angleStep) = 0;
541 virtual double getAngleStep() const = 0;
543 //! Angle votes threshold.
544 virtual void setAngleThresh(int angleThresh) = 0;
545 virtual int getAngleThresh() const = 0;
547 //! Minimal scale to detect.
548 virtual void setMinScale(double minScale) = 0;
549 virtual double getMinScale() const = 0;
551 //! Maximal scale to detect.
552 virtual void setMaxScale(double maxScale) = 0;
553 virtual double getMaxScale() const = 0;
556 virtual void setScaleStep(double scaleStep) = 0;
557 virtual double getScaleStep() const = 0;
559 //! Scale votes threshold.
560 virtual void setScaleThresh(int scaleThresh) = 0;
561 virtual int getScaleThresh() const = 0;
563 //! Position votes threshold.
564 virtual void setPosThresh(int posThresh) = 0;
565 virtual int getPosThresh() const = 0;
569 class CV_EXPORTS_W CLAHE : public Algorithm
572 CV_WRAP virtual void apply(InputArray src, OutputArray dst) = 0;
574 CV_WRAP virtual void setClipLimit(double clipLimit) = 0;
575 CV_WRAP virtual double getClipLimit() const = 0;
577 CV_WRAP virtual void setTilesGridSize(Size tileGridSize) = 0;
578 CV_WRAP virtual Size getTilesGridSize() const = 0;
580 CV_WRAP virtual void collectGarbage() = 0;
584 class CV_EXPORTS_W Subdiv2D
587 enum { PTLOC_ERROR = -2,
588 PTLOC_OUTSIDE_RECT = -1,
594 enum { NEXT_AROUND_ORG = 0x00,
595 NEXT_AROUND_DST = 0x22,
596 PREV_AROUND_ORG = 0x11,
597 PREV_AROUND_DST = 0x33,
598 NEXT_AROUND_LEFT = 0x13,
599 NEXT_AROUND_RIGHT = 0x31,
600 PREV_AROUND_LEFT = 0x20,
601 PREV_AROUND_RIGHT = 0x02
605 CV_WRAP Subdiv2D(Rect rect);
606 CV_WRAP void initDelaunay(Rect rect);
608 CV_WRAP int insert(Point2f pt);
609 CV_WRAP void insert(const std::vector<Point2f>& ptvec);
610 CV_WRAP int locate(Point2f pt, CV_OUT int& edge, CV_OUT int& vertex);
612 CV_WRAP int findNearest(Point2f pt, CV_OUT Point2f* nearestPt = 0);
613 CV_WRAP void getEdgeList(CV_OUT std::vector<Vec4f>& edgeList) const;
614 CV_WRAP void getTriangleList(CV_OUT std::vector<Vec6f>& triangleList) const;
615 CV_WRAP void getVoronoiFacetList(const std::vector<int>& idx, CV_OUT std::vector<std::vector<Point2f> >& facetList,
616 CV_OUT std::vector<Point2f>& facetCenters);
618 CV_WRAP Point2f getVertex(int vertex, CV_OUT int* firstEdge = 0) const;
620 CV_WRAP int getEdge( int edge, int nextEdgeType ) const;
621 CV_WRAP int nextEdge(int edge) const;
622 CV_WRAP int rotateEdge(int edge, int rotate) const;
623 CV_WRAP int symEdge(int edge) const;
624 CV_WRAP int edgeOrg(int edge, CV_OUT Point2f* orgpt = 0) const;
625 CV_WRAP int edgeDst(int edge, CV_OUT Point2f* dstpt = 0) const;
629 void deleteEdge(int edge);
630 int newPoint(Point2f pt, bool isvirtual, int firstEdge = 0);
631 void deletePoint(int vtx);
632 void setEdgePoints( int edge, int orgPt, int dstPt );
633 void splice( int edgeA, int edgeB );
634 int connectEdges( int edgeA, int edgeB );
635 void swapEdges( int edge );
636 int isRightOf(Point2f pt, int edge) const;
639 void checkSubdiv() const;
641 struct CV_EXPORTS Vertex
644 Vertex(Point2f pt, bool _isvirtual, int _firstEdge=0);
645 bool isvirtual() const;
653 struct CV_EXPORTS QuadEdge
656 QuadEdge(int edgeidx);
663 std::vector<Vertex> vtx;
664 std::vector<QuadEdge> qedges;
674 class CV_EXPORTS_W LineSegmentDetector : public Algorithm
678 * Detect lines in the input image.
680 * @param _image A grayscale(CV_8UC1) input image.
681 * If only a roi needs to be selected, use
682 * lsd_ptr->detect(image(roi), ..., lines);
683 * lines += Scalar(roi.x, roi.y, roi.x, roi.y);
684 * @param _lines Return: A vector of Vec4i elements specifying the beginning and ending point of a line.
685 * Where Vec4i is (x1, y1, x2, y2), point 1 is the start, point 2 - end.
686 * Returned lines are strictly oriented depending on the gradient.
687 * @param width Return: Vector of widths of the regions, where the lines are found. E.g. Width of line.
688 * @param prec Return: Vector of precisions with which the lines are found.
689 * @param nfa Return: Vector containing number of false alarms in the line region, with precision of 10%.
690 * The bigger the value, logarithmically better the detection.
691 * * -1 corresponds to 10 mean false alarms
692 * * 0 corresponds to 1 mean false alarm
693 * * 1 corresponds to 0.1 mean false alarms
694 * This vector will be calculated _only_ when the objects type is REFINE_ADV
696 CV_WRAP virtual void detect(InputArray _image, OutputArray _lines,
697 OutputArray width = noArray(), OutputArray prec = noArray(),
698 OutputArray nfa = noArray()) = 0;
701 * Draw lines on the given canvas.
702 * @param _image The image, where lines will be drawn.
703 * Should have the size of the image, where the lines were found
704 * @param lines The lines that need to be drawn
706 CV_WRAP virtual void drawSegments(InputOutputArray _image, InputArray lines) = 0;
709 * Draw both vectors on the image canvas. Uses blue for lines 1 and red for lines 2.
710 * @param size The size of the image, where lines were found.
711 * @param lines1 The first lines that need to be drawn. Color - Blue.
712 * @param lines2 The second lines that need to be drawn. Color - Red.
713 * @param _image Optional image, where lines will be drawn.
714 * Should have the size of the image, where the lines were found
715 * @return The number of mismatching pixels between lines1 and lines2.
717 CV_WRAP virtual int compareSegments(const Size& size, InputArray lines1, InputArray lines2, InputOutputArray _image = noArray()) = 0;
719 virtual ~LineSegmentDetector() { }
722 //! Returns a pointer to a LineSegmentDetector class.
723 CV_EXPORTS_W Ptr<LineSegmentDetector> createLineSegmentDetector(
724 int _refine = LSD_REFINE_STD, double _scale = 0.8,
725 double _sigma_scale = 0.6, double _quant = 2.0, double _ang_th = 22.5,
726 double _log_eps = 0, double _density_th = 0.7, int _n_bins = 1024);
728 //! returns the Gaussian kernel with the specified parameters
729 CV_EXPORTS_W Mat getGaussianKernel( int ksize, double sigma, int ktype = CV_64F );
731 //! initializes kernels of the generalized Sobel operator
732 CV_EXPORTS_W void getDerivKernels( OutputArray kx, OutputArray ky,
733 int dx, int dy, int ksize,
734 bool normalize = false, int ktype = CV_32F );
736 //! returns the Gabor kernel with the specified parameters
737 CV_EXPORTS_W Mat getGaborKernel( Size ksize, double sigma, double theta, double lambd,
738 double gamma, double psi = CV_PI*0.5, int ktype = CV_64F );
740 //! returns "magic" border value for erosion and dilation. It is automatically transformed to Scalar::all(-DBL_MAX) for dilation.
741 static inline Scalar morphologyDefaultBorderValue() { return Scalar::all(DBL_MAX); }
743 //! returns structuring element of the specified shape and size
744 CV_EXPORTS_W Mat getStructuringElement(int shape, Size ksize, Point anchor = Point(-1,-1));
746 //! smooths the image using median filter.
747 CV_EXPORTS_W void medianBlur( InputArray src, OutputArray dst, int ksize );
749 //! smooths the image using Gaussian filter.
750 CV_EXPORTS_W void GaussianBlur( InputArray src, OutputArray dst, Size ksize,
751 double sigmaX, double sigmaY = 0,
752 int borderType = BORDER_DEFAULT );
754 //! smooths the image using bilateral filter
755 CV_EXPORTS_W void bilateralFilter( InputArray src, OutputArray dst, int d,
756 double sigmaColor, double sigmaSpace,
757 int borderType = BORDER_DEFAULT );
759 //! smooths the image using the box filter. Each pixel is processed in O(1) time
760 CV_EXPORTS_W void boxFilter( InputArray src, OutputArray dst, int ddepth,
761 Size ksize, Point anchor = Point(-1,-1),
762 bool normalize = true,
763 int borderType = BORDER_DEFAULT );
765 CV_EXPORTS_W void sqrBoxFilter( InputArray _src, OutputArray _dst, int ddepth,
766 Size ksize, Point anchor = Point(-1, -1),
767 bool normalize = true,
768 int borderType = BORDER_DEFAULT );
770 //! a synonym for normalized box filter
771 CV_EXPORTS_W void blur( InputArray src, OutputArray dst,
772 Size ksize, Point anchor = Point(-1,-1),
773 int borderType = BORDER_DEFAULT );
775 //! applies non-separable 2D linear filter to the image
776 CV_EXPORTS_W void filter2D( InputArray src, OutputArray dst, int ddepth,
777 InputArray kernel, Point anchor = Point(-1,-1),
778 double delta = 0, int borderType = BORDER_DEFAULT );
780 //! applies separable 2D linear filter to the image
781 CV_EXPORTS_W void sepFilter2D( InputArray src, OutputArray dst, int ddepth,
782 InputArray kernelX, InputArray kernelY,
783 Point anchor = Point(-1,-1),
784 double delta = 0, int borderType = BORDER_DEFAULT );
786 //! applies generalized Sobel operator to the image
787 CV_EXPORTS_W void Sobel( InputArray src, OutputArray dst, int ddepth,
788 int dx, int dy, int ksize = 3,
789 double scale = 1, double delta = 0,
790 int borderType = BORDER_DEFAULT );
792 //! applies the vertical or horizontal Scharr operator to the image
793 CV_EXPORTS_W void Scharr( InputArray src, OutputArray dst, int ddepth,
794 int dx, int dy, double scale = 1, double delta = 0,
795 int borderType = BORDER_DEFAULT );
797 //! applies Laplacian operator to the image
798 CV_EXPORTS_W void Laplacian( InputArray src, OutputArray dst, int ddepth,
799 int ksize = 1, double scale = 1, double delta = 0,
800 int borderType = BORDER_DEFAULT );
802 //! applies Canny edge detector and produces the edge map.
803 CV_EXPORTS_W void Canny( InputArray image, OutputArray edges,
804 double threshold1, double threshold2,
805 int apertureSize = 3, bool L2gradient = false );
807 //! computes minimum eigen value of 2x2 derivative covariation matrix at each pixel - the cornerness criteria
808 CV_EXPORTS_W void cornerMinEigenVal( InputArray src, OutputArray dst,
809 int blockSize, int ksize = 3,
810 int borderType = BORDER_DEFAULT );
812 //! computes Harris cornerness criteria at each image pixel
813 CV_EXPORTS_W void cornerHarris( InputArray src, OutputArray dst, int blockSize,
815 int borderType = BORDER_DEFAULT );
817 //! computes both eigenvalues and the eigenvectors of 2x2 derivative covariation matrix at each pixel. The output is stored as 6-channel matrix.
818 CV_EXPORTS_W void cornerEigenValsAndVecs( InputArray src, OutputArray dst,
819 int blockSize, int ksize,
820 int borderType = BORDER_DEFAULT );
822 //! computes another complex cornerness criteria at each pixel
823 CV_EXPORTS_W void preCornerDetect( InputArray src, OutputArray dst, int ksize,
824 int borderType = BORDER_DEFAULT );
826 //! adjusts the corner locations with sub-pixel accuracy to maximize the certain cornerness criteria
827 CV_EXPORTS_W void cornerSubPix( InputArray image, InputOutputArray corners,
828 Size winSize, Size zeroZone,
829 TermCriteria criteria );
831 //! finds the strong enough corners where the cornerMinEigenVal() or cornerHarris() report the local maxima
832 CV_EXPORTS_W void goodFeaturesToTrack( InputArray image, OutputArray corners,
833 int maxCorners, double qualityLevel, double minDistance,
834 InputArray mask = noArray(), int blockSize = 3,
835 bool useHarrisDetector = false, double k = 0.04 );
837 //! finds lines in the black-n-white image using the standard or pyramid Hough transform
838 CV_EXPORTS_W void HoughLines( InputArray image, OutputArray lines,
839 double rho, double theta, int threshold,
840 double srn = 0, double stn = 0,
841 double min_theta = 0, double max_theta = CV_PI );
843 //! finds line segments in the black-n-white image using probabilistic Hough transform
844 CV_EXPORTS_W void HoughLinesP( InputArray image, OutputArray lines,
845 double rho, double theta, int threshold,
846 double minLineLength = 0, double maxLineGap = 0 );
848 //! finds circles in the grayscale image using 2+1 gradient Hough transform
849 CV_EXPORTS_W void HoughCircles( InputArray image, OutputArray circles,
850 int method, double dp, double minDist,
851 double param1 = 100, double param2 = 100,
852 int minRadius = 0, int maxRadius = 0 );
854 //! erodes the image (applies the local minimum operator)
855 CV_EXPORTS_W void erode( InputArray src, OutputArray dst, InputArray kernel,
856 Point anchor = Point(-1,-1), int iterations = 1,
857 int borderType = BORDER_CONSTANT,
858 const Scalar& borderValue = morphologyDefaultBorderValue() );
860 //! dilates the image (applies the local maximum operator)
861 CV_EXPORTS_W void dilate( InputArray src, OutputArray dst, InputArray kernel,
862 Point anchor = Point(-1,-1), int iterations = 1,
863 int borderType = BORDER_CONSTANT,
864 const Scalar& borderValue = morphologyDefaultBorderValue() );
866 //! applies an advanced morphological operation to the image
867 CV_EXPORTS_W void morphologyEx( InputArray src, OutputArray dst,
868 int op, InputArray kernel,
869 Point anchor = Point(-1,-1), int iterations = 1,
870 int borderType = BORDER_CONSTANT,
871 const Scalar& borderValue = morphologyDefaultBorderValue() );
873 //! resizes the image
874 CV_EXPORTS_W void resize( InputArray src, OutputArray dst,
875 Size dsize, double fx = 0, double fy = 0,
876 int interpolation = INTER_LINEAR );
878 //! warps the image using affine transformation
879 CV_EXPORTS_W void warpAffine( InputArray src, OutputArray dst,
880 InputArray M, Size dsize,
881 int flags = INTER_LINEAR,
882 int borderMode = BORDER_CONSTANT,
883 const Scalar& borderValue = Scalar());
885 //! warps the image using perspective transformation
886 CV_EXPORTS_W void warpPerspective( InputArray src, OutputArray dst,
887 InputArray M, Size dsize,
888 int flags = INTER_LINEAR,
889 int borderMode = BORDER_CONSTANT,
890 const Scalar& borderValue = Scalar());
892 //! warps the image using the precomputed maps. The maps are stored in either floating-point or integer fixed-point format
893 CV_EXPORTS_W void remap( InputArray src, OutputArray dst,
894 InputArray map1, InputArray map2,
895 int interpolation, int borderMode = BORDER_CONSTANT,
896 const Scalar& borderValue = Scalar());
898 //! converts maps for remap from floating-point to fixed-point format or backwards
899 CV_EXPORTS_W void convertMaps( InputArray map1, InputArray map2,
900 OutputArray dstmap1, OutputArray dstmap2,
901 int dstmap1type, bool nninterpolation = false );
903 //! returns 2x3 affine transformation matrix for the planar rotation.
904 CV_EXPORTS_W Mat getRotationMatrix2D( Point2f center, double angle, double scale );
906 //! returns 3x3 perspective transformation for the corresponding 4 point pairs.
907 CV_EXPORTS Mat getPerspectiveTransform( const Point2f src[], const Point2f dst[] );
909 //! returns 2x3 affine transformation for the corresponding 3 point pairs.
910 CV_EXPORTS Mat getAffineTransform( const Point2f src[], const Point2f dst[] );
912 //! computes 2x3 affine transformation matrix that is inverse to the specified 2x3 affine transformation.
913 CV_EXPORTS_W void invertAffineTransform( InputArray M, OutputArray iM );
915 CV_EXPORTS_W Mat getPerspectiveTransform( InputArray src, InputArray dst );
917 CV_EXPORTS_W Mat getAffineTransform( InputArray src, InputArray dst );
919 //! extracts rectangle from the image at sub-pixel location
920 CV_EXPORTS_W void getRectSubPix( InputArray image, Size patchSize,
921 Point2f center, OutputArray patch, int patchType = -1 );
923 //! computes the log polar transform
924 CV_EXPORTS_W void logPolar( InputArray src, OutputArray dst,
925 Point2f center, double M, int flags );
927 //! computes the linear polar transform
928 CV_EXPORTS_W void linearPolar( InputArray src, OutputArray dst,
929 Point2f center, double maxRadius, int flags );
931 //! computes the integral image
932 CV_EXPORTS_W void integral( InputArray src, OutputArray sum, int sdepth = -1 );
934 //! computes the integral image and integral for the squared image
935 CV_EXPORTS_AS(integral2) void integral( InputArray src, OutputArray sum,
936 OutputArray sqsum, int sdepth = -1, int sqdepth = -1 );
938 //! computes the integral image, integral for the squared image and the tilted integral image
939 CV_EXPORTS_AS(integral3) void integral( InputArray src, OutputArray sum,
940 OutputArray sqsum, OutputArray tilted,
941 int sdepth = -1, int sqdepth = -1 );
943 //! adds image to the accumulator (dst += src). Unlike cv::add, dst and src can have different types.
944 CV_EXPORTS_W void accumulate( InputArray src, InputOutputArray dst,
945 InputArray mask = noArray() );
947 //! adds squared src image to the accumulator (dst += src*src).
948 CV_EXPORTS_W void accumulateSquare( InputArray src, InputOutputArray dst,
949 InputArray mask = noArray() );
950 //! adds product of the 2 images to the accumulator (dst += src1*src2).
951 CV_EXPORTS_W void accumulateProduct( InputArray src1, InputArray src2,
952 InputOutputArray dst, InputArray mask=noArray() );
954 //! updates the running average (dst = dst*(1-alpha) + src*alpha)
955 CV_EXPORTS_W void accumulateWeighted( InputArray src, InputOutputArray dst,
956 double alpha, InputArray mask = noArray() );
958 CV_EXPORTS_W Point2d phaseCorrelate(InputArray src1, InputArray src2,
959 InputArray window = noArray(), CV_OUT double* response = 0);
961 CV_EXPORTS_W void createHanningWindow(OutputArray dst, Size winSize, int type);
963 //! applies fixed threshold to the image
964 CV_EXPORTS_W double threshold( InputArray src, OutputArray dst,
965 double thresh, double maxval, int type );
968 //! applies variable (adaptive) threshold to the image
969 CV_EXPORTS_W void adaptiveThreshold( InputArray src, OutputArray dst,
970 double maxValue, int adaptiveMethod,
971 int thresholdType, int blockSize, double C );
973 //! smooths and downsamples the image
974 CV_EXPORTS_W void pyrDown( InputArray src, OutputArray dst,
975 const Size& dstsize = Size(), int borderType = BORDER_DEFAULT );
977 //! upsamples and smoothes the image
978 CV_EXPORTS_W void pyrUp( InputArray src, OutputArray dst,
979 const Size& dstsize = Size(), int borderType = BORDER_DEFAULT );
981 //! builds the gaussian pyramid using pyrDown() as a basic operation
982 CV_EXPORTS void buildPyramid( InputArray src, OutputArrayOfArrays dst,
983 int maxlevel, int borderType = BORDER_DEFAULT );
985 //! corrects lens distortion for the given camera matrix and distortion coefficients
986 CV_EXPORTS_W void undistort( InputArray src, OutputArray dst,
987 InputArray cameraMatrix,
988 InputArray distCoeffs,
989 InputArray newCameraMatrix = noArray() );
991 //! initializes maps for cv::remap() to correct lens distortion and optionally rectify the image
992 CV_EXPORTS_W void initUndistortRectifyMap( InputArray cameraMatrix, InputArray distCoeffs,
993 InputArray R, InputArray newCameraMatrix,
994 Size size, int m1type, OutputArray map1, OutputArray map2 );
996 //! initializes maps for cv::remap() for wide-angle
997 CV_EXPORTS_W float initWideAngleProjMap( InputArray cameraMatrix, InputArray distCoeffs,
998 Size imageSize, int destImageWidth,
999 int m1type, OutputArray map1, OutputArray map2,
1000 int projType = PROJ_SPHERICAL_EQRECT, double alpha = 0);
1002 //! returns the default new camera matrix (by default it is the same as cameraMatrix unless centerPricipalPoint=true)
1003 CV_EXPORTS_W Mat getDefaultNewCameraMatrix( InputArray cameraMatrix, Size imgsize = Size(),
1004 bool centerPrincipalPoint = false );
1006 //! returns points' coordinates after lens distortion correction
1007 CV_EXPORTS_W void undistortPoints( InputArray src, OutputArray dst,
1008 InputArray cameraMatrix, InputArray distCoeffs,
1009 InputArray R = noArray(), InputArray P = noArray());
1011 //! computes the joint dense histogram for a set of images.
1012 CV_EXPORTS void calcHist( const Mat* images, int nimages,
1013 const int* channels, InputArray mask,
1014 OutputArray hist, int dims, const int* histSize,
1015 const float** ranges, bool uniform = true, bool accumulate = false );
1017 //! computes the joint sparse histogram for a set of images.
1018 CV_EXPORTS void calcHist( const Mat* images, int nimages,
1019 const int* channels, InputArray mask,
1020 SparseMat& hist, int dims,
1021 const int* histSize, const float** ranges,
1022 bool uniform = true, bool accumulate = false );
1024 CV_EXPORTS_W void calcHist( InputArrayOfArrays images,
1025 const std::vector<int>& channels,
1026 InputArray mask, OutputArray hist,
1027 const std::vector<int>& histSize,
1028 const std::vector<float>& ranges,
1029 bool accumulate = false );
1031 //! computes back projection for the set of images
1032 CV_EXPORTS void calcBackProject( const Mat* images, int nimages,
1033 const int* channels, InputArray hist,
1034 OutputArray backProject, const float** ranges,
1035 double scale = 1, bool uniform = true );
1037 //! computes back projection for the set of images
1038 CV_EXPORTS void calcBackProject( const Mat* images, int nimages,
1039 const int* channels, const SparseMat& hist,
1040 OutputArray backProject, const float** ranges,
1041 double scale = 1, bool uniform = true );
1043 CV_EXPORTS_W void calcBackProject( InputArrayOfArrays images, const std::vector<int>& channels,
1044 InputArray hist, OutputArray dst,
1045 const std::vector<float>& ranges,
1048 //! compares two histograms stored in dense arrays
1049 CV_EXPORTS_W double compareHist( InputArray H1, InputArray H2, int method );
1051 //! compares two histograms stored in sparse arrays
1052 CV_EXPORTS double compareHist( const SparseMat& H1, const SparseMat& H2, int method );
1054 //! normalizes the grayscale image brightness and contrast by normalizing its histogram
1055 CV_EXPORTS_W void equalizeHist( InputArray src, OutputArray dst );
1057 CV_EXPORTS float EMD( InputArray signature1, InputArray signature2,
1058 int distType, InputArray cost=noArray(),
1059 float* lowerBound = 0, OutputArray flow = noArray() );
1061 //! segments the image using watershed algorithm
1062 CV_EXPORTS_W void watershed( InputArray image, InputOutputArray markers );
1064 //! filters image using meanshift algorithm
1065 CV_EXPORTS_W void pyrMeanShiftFiltering( InputArray src, OutputArray dst,
1066 double sp, double sr, int maxLevel = 1,
1067 TermCriteria termcrit=TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS,5,1) );
1069 //! segments the image using GrabCut algorithm
1070 CV_EXPORTS_W void grabCut( InputArray img, InputOutputArray mask, Rect rect,
1071 InputOutputArray bgdModel, InputOutputArray fgdModel,
1072 int iterCount, int mode = GC_EVAL );
1075 //! builds the discrete Voronoi diagram
1076 CV_EXPORTS_AS(distanceTransformWithLabels) void distanceTransform( InputArray src, OutputArray dst,
1077 OutputArray labels, int distanceType, int maskSize,
1078 int labelType = DIST_LABEL_CCOMP );
1080 //! computes the distance transform map
1081 CV_EXPORTS_W void distanceTransform( InputArray src, OutputArray dst,
1082 int distanceType, int maskSize, int dstType=CV_32F);
1085 //! fills the semi-uniform image region starting from the specified seed point
1086 CV_EXPORTS int floodFill( InputOutputArray image,
1087 Point seedPoint, Scalar newVal, CV_OUT Rect* rect = 0,
1088 Scalar loDiff = Scalar(), Scalar upDiff = Scalar(),
1091 //! fills the semi-uniform image region and/or the mask starting from the specified seed point
1092 CV_EXPORTS_W int floodFill( InputOutputArray image, InputOutputArray mask,
1093 Point seedPoint, Scalar newVal, CV_OUT Rect* rect=0,
1094 Scalar loDiff = Scalar(), Scalar upDiff = Scalar(),
1097 //! converts image from one color space to another
1098 CV_EXPORTS_W void cvtColor( InputArray src, OutputArray dst, int code, int dstCn = 0 );
1100 // main function for all demosaicing procceses
1101 CV_EXPORTS_W void demosaicing(InputArray _src, OutputArray _dst, int code, int dcn = 0);
1103 //! computes moments of the rasterized shape or a vector of points
1104 CV_EXPORTS_W Moments moments( InputArray array, bool binaryImage = false );
1106 //! computes 7 Hu invariants from the moments
1107 CV_EXPORTS void HuMoments( const Moments& moments, double hu[7] );
1109 CV_EXPORTS_W void HuMoments( const Moments& m, OutputArray hu );
1111 //! computes the proximity map for the raster template and the image where the template is searched for
1112 CV_EXPORTS_W void matchTemplate( InputArray image, InputArray templ,
1113 OutputArray result, int method );
1116 // computes the connected components labeled image of boolean image ``image``
1117 // with 4 or 8 way connectivity - returns N, the total
1118 // number of labels [0, N-1] where 0 represents the background label.
1119 // ltype specifies the output label image type, an important
1120 // consideration based on the total number of labels or
1121 // alternatively the total number of pixels in the source image.
1122 CV_EXPORTS_W int connectedComponents(InputArray image, OutputArray labels,
1123 int connectivity = 8, int ltype = CV_32S);
1125 CV_EXPORTS_W int connectedComponentsWithStats(InputArray image, OutputArray labels,
1126 OutputArray stats, OutputArray centroids,
1127 int connectivity = 8, int ltype = CV_32S);
1130 //! retrieves contours and the hierarchical information from black-n-white image.
1131 CV_EXPORTS_W void findContours( InputOutputArray image, OutputArrayOfArrays contours,
1132 OutputArray hierarchy, int mode,
1133 int method, Point offset = Point());
1135 //! retrieves contours from black-n-white image.
1136 CV_EXPORTS void findContours( InputOutputArray image, OutputArrayOfArrays contours,
1137 int mode, int method, Point offset = Point());
1139 //! approximates contour or a curve using Douglas-Peucker algorithm
1140 CV_EXPORTS_W void approxPolyDP( InputArray curve,
1141 OutputArray approxCurve,
1142 double epsilon, bool closed );
1144 //! computes the contour perimeter (closed=true) or a curve length
1145 CV_EXPORTS_W double arcLength( InputArray curve, bool closed );
1147 //! computes the bounding rectangle for a contour
1148 CV_EXPORTS_W Rect boundingRect( InputArray points );
1150 //! computes the contour area
1151 CV_EXPORTS_W double contourArea( InputArray contour, bool oriented = false );
1153 //! computes the minimal rotated rectangle for a set of points
1154 CV_EXPORTS_W RotatedRect minAreaRect( InputArray points );
1156 //! computes boxpoints
1157 CV_EXPORTS_W void boxPoints(RotatedRect box, OutputArray points);
1159 //! computes the minimal enclosing circle for a set of points
1160 CV_EXPORTS_W void minEnclosingCircle( InputArray points,
1161 CV_OUT Point2f& center, CV_OUT float& radius );
1163 //! computes the minimal enclosing triangle for a set of points and returns its area
1164 CV_EXPORTS_W double minEnclosingTriangle( InputArray points, CV_OUT OutputArray triangle );
1166 //! matches two contours using one of the available algorithms
1167 CV_EXPORTS_W double matchShapes( InputArray contour1, InputArray contour2,
1168 int method, double parameter );
1170 //! computes convex hull for a set of 2D points.
1171 CV_EXPORTS_W void convexHull( InputArray points, OutputArray hull,
1172 bool clockwise = false, bool returnPoints = true );
1174 //! computes the contour convexity defects
1175 CV_EXPORTS_W void convexityDefects( InputArray contour, InputArray convexhull, OutputArray convexityDefects );
1177 //! returns true if the contour is convex. Does not support contours with self-intersection
1178 CV_EXPORTS_W bool isContourConvex( InputArray contour );
1180 //! finds intersection of two convex polygons
1181 CV_EXPORTS_W float intersectConvexConvex( InputArray _p1, InputArray _p2,
1182 OutputArray _p12, bool handleNested = true );
1184 //! fits ellipse to the set of 2D points
1185 CV_EXPORTS_W RotatedRect fitEllipse( InputArray points );
1187 //! fits line to the set of 2D points using M-estimator algorithm
1188 CV_EXPORTS_W void fitLine( InputArray points, OutputArray line, int distType,
1189 double param, double reps, double aeps );
1191 //! checks if the point is inside the contour. Optionally computes the signed distance from the point to the contour boundary
1192 CV_EXPORTS_W double pointPolygonTest( InputArray contour, Point2f pt, bool measureDist );
1194 //! computes whether two rotated rectangles intersect and returns the vertices of the intersecting region
1195 CV_EXPORTS_W int rotatedRectangleIntersection( const RotatedRect& rect1, const RotatedRect& rect2, OutputArray intersectingRegion );
1197 CV_EXPORTS_W Ptr<CLAHE> createCLAHE(double clipLimit = 40.0, Size tileGridSize = Size(8, 8));
1199 //! Ballard, D.H. (1981). Generalizing the Hough transform to detect arbitrary shapes. Pattern Recognition 13 (2): 111-122.
1200 //! Detects position only without traslation and rotation
1201 CV_EXPORTS Ptr<GeneralizedHoughBallard> createGeneralizedHoughBallard();
1203 //! Guil, N., González-Linares, J.M. and Zapata, E.L. (1999). Bidimensional shape detection using an invariant approach. Pattern Recognition 32 (6): 1025-1038.
1204 //! Detects position, traslation and rotation
1205 CV_EXPORTS Ptr<GeneralizedHoughGuil> createGeneralizedHoughGuil();
1207 //! Performs linear blending of two images
1208 CV_EXPORTS void blendLinear(InputArray src1, InputArray src2, InputArray weights1, InputArray weights2, OutputArray dst);
1212 COLORMAP_AUTUMN = 0,
1215 COLORMAP_WINTER = 3,
1216 COLORMAP_RAINBOW = 4,
1218 COLORMAP_SUMMER = 6,
1219 COLORMAP_SPRING = 7,
1226 CV_EXPORTS_W void applyColorMap(InputArray src, OutputArray dst, int colormap);
1229 //! draws the line segment (pt1, pt2) in the image
1230 CV_EXPORTS_W void line(InputOutputArray img, Point pt1, Point pt2, const Scalar& color,
1231 int thickness = 1, int lineType = LINE_8, int shift = 0);
1233 //! draws an arrow from pt1 to pt2 in the image
1234 CV_EXPORTS_W void arrowedLine(InputOutputArray img, Point pt1, Point pt2, const Scalar& color,
1235 int thickness=1, int line_type=8, int shift=0, double tipLength=0.1);
1237 //! draws the rectangle outline or a solid rectangle with the opposite corners pt1 and pt2 in the image
1238 CV_EXPORTS_W void rectangle(InputOutputArray img, Point pt1, Point pt2,
1239 const Scalar& color, int thickness = 1,
1240 int lineType = LINE_8, int shift = 0);
1242 //! draws the rectangle outline or a solid rectangle covering rec in the image
1243 CV_EXPORTS void rectangle(CV_IN_OUT Mat& img, Rect rec,
1244 const Scalar& color, int thickness = 1,
1245 int lineType = LINE_8, int shift = 0);
1247 //! draws the circle outline or a solid circle in the image
1248 CV_EXPORTS_W void circle(InputOutputArray img, Point center, int radius,
1249 const Scalar& color, int thickness = 1,
1250 int lineType = LINE_8, int shift = 0);
1252 //! draws an elliptic arc, ellipse sector or a rotated ellipse in the image
1253 CV_EXPORTS_W void ellipse(InputOutputArray img, Point center, Size axes,
1254 double angle, double startAngle, double endAngle,
1255 const Scalar& color, int thickness = 1,
1256 int lineType = LINE_8, int shift = 0);
1258 //! draws a rotated ellipse in the image
1259 CV_EXPORTS_W void ellipse(InputOutputArray img, const RotatedRect& box, const Scalar& color,
1260 int thickness = 1, int lineType = LINE_8);
1262 //! draws a filled convex polygon in the image
1263 CV_EXPORTS void fillConvexPoly(Mat& img, const Point* pts, int npts,
1264 const Scalar& color, int lineType = LINE_8,
1267 CV_EXPORTS_W void fillConvexPoly(InputOutputArray img, InputArray points,
1268 const Scalar& color, int lineType = LINE_8,
1271 //! fills an area bounded by one or more polygons
1272 CV_EXPORTS void fillPoly(Mat& img, const Point** pts,
1273 const int* npts, int ncontours,
1274 const Scalar& color, int lineType = LINE_8, int shift = 0,
1275 Point offset = Point() );
1277 CV_EXPORTS_W void fillPoly(InputOutputArray img, InputArrayOfArrays pts,
1278 const Scalar& color, int lineType = LINE_8, int shift = 0,
1279 Point offset = Point() );
1281 //! draws one or more polygonal curves
1282 CV_EXPORTS void polylines(Mat& img, const Point* const* pts, const int* npts,
1283 int ncontours, bool isClosed, const Scalar& color,
1284 int thickness = 1, int lineType = LINE_8, int shift = 0 );
1286 CV_EXPORTS_W void polylines(InputOutputArray img, InputArrayOfArrays pts,
1287 bool isClosed, const Scalar& color,
1288 int thickness = 1, int lineType = LINE_8, int shift = 0 );
1290 //! draws contours in the image
1291 CV_EXPORTS_W void drawContours( InputOutputArray image, InputArrayOfArrays contours,
1292 int contourIdx, const Scalar& color,
1293 int thickness = 1, int lineType = LINE_8,
1294 InputArray hierarchy = noArray(),
1295 int maxLevel = INT_MAX, Point offset = Point() );
1297 //! clips the line segment by the rectangle Rect(0, 0, imgSize.width, imgSize.height)
1298 CV_EXPORTS bool clipLine(Size imgSize, CV_IN_OUT Point& pt1, CV_IN_OUT Point& pt2);
1300 //! clips the line segment by the rectangle imgRect
1301 CV_EXPORTS_W bool clipLine(Rect imgRect, CV_OUT CV_IN_OUT Point& pt1, CV_OUT CV_IN_OUT Point& pt2);
1303 //! converts elliptic arc to a polygonal curve
1304 CV_EXPORTS_W void ellipse2Poly( Point center, Size axes, int angle,
1305 int arcStart, int arcEnd, int delta,
1306 CV_OUT std::vector<Point>& pts );
1308 //! renders text string in the image
1309 CV_EXPORTS_W void putText( InputOutputArray img, const String& text, Point org,
1310 int fontFace, double fontScale, Scalar color,
1311 int thickness = 1, int lineType = LINE_8,
1312 bool bottomLeftOrigin = false );
1314 //! returns bounding box of the text string
1315 CV_EXPORTS_W Size getTextSize(const String& text, int fontFace,
1316 double fontScale, int thickness,
1317 CV_OUT int* baseLine);