8.4.2.11. contours
(packages/opencv/contours.lsh)


dummy function that adds OpenCV C header files in C file

8.4.2.11.0. (cvFindContours array stor first hsize mode method)
(packages/opencv/contours.lsh)


 /*F///////////////////////////////////////////////////////////////////////////////////////
 //    Name:    cvFindContours
 //    Purpose: finds contours on the binary image
 //    Context:
 //    Parameters:
 //         img - binary image(depth is IPL_DEPTH_8U or IPL_DEPTH_8S, single channel).
 //         storage - memory storage where the contours will be stored
 //         firstContour - output parameter. First contour on the highest level.
 //         headerSize - size of contours headers.
 //         mode - contour retrieving mode.
 //                  CV_RETR_EXTERNAL - get only the most external contours(list).
 //                  CV_RETR_LIST     - get all the contours without any hierarchical links
 //                                    (list).
 //                  CV_RETR_CCOMP    - get all the contours and make holes as child
 //                                     contours of corresponding external contour
 //                                    (two-level hierarchical structure)
 //                  CV_RETR_TREE     - get all the contours and build all
 //                                     hierarchical links(tree).
 //         method - approximation method
 //                CV_CHAIN_CODE    - output contours in chain-coded form(Freeman code).
 //                              The rest of methods approximate chain code with polyline
 //                CV_CHAIN_APPROX_NONE - no compression. Every point of digital curve
 //                                       is coded
 //                CV_CHAIN_APPROX_SIMPLE - horizontal, vertical and diagonal segments are
 //                                         are coded with ending vertices (by default).
 //                CV_CHAIN_APPROX_TC89_L1 - Teh-Chin algorithm, L1 curvature
 //                CV_CHAIN_APPROX_TC89_KCOS - Teh-Chin algorithm, k-cosine curvature
 //         offset - a cvPoint object
 //    Returns:
 //      Number of contours found.
 //F*/
 OPENCVAPI  int  cvFindContours( CvArr* array, CvMemStorage* storage,
                            CvSeq**  firstContour,
                            int  headerSize CV_DEFAULT(sizeof(CvContour)),
                            CvContourRetrievalMode mode CV_DEFAULT( CV_RETR_LIST ),
                            CvChainApproxMethod method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE));


8.4.2.11.1. (cvStartFindContours array stor hsize mode method)
(packages/opencv/contours.lsh)


 /*F///////////////////////////////////////////////////////////////////////////////////////
 //    Name:    cvStartFindContours
 //    Purpose: starts iterrative process of contours retrieving
 //    Context:
 //    Parameters:
 //         img - binary image(depth is IPL_DEPTH_8U or IPL_DEPTH_8S, single channel).
 //         storage - memory storage where the contours will be stored
 //         header_size - size of contours headers.
 //         mode - contour retrieving mode(see cvFindContours description)
 //         method - approximation method(see cvFindContours description)
 //         offset - a cvPoint object
 //    Returns:
 //      contour scanner state.
 //F*/
 OPENCVAPI  CvContourScanner   cvStartFindContours( CvArr* array, CvMemStorage* storage,
                                         int header_size, CvContourRetrievalMode mode,
                                         CvChainApproxMethod method );


8.4.2.11.2. (cvFindNextContour scanner)
(packages/opencv/contours.lsh)


 /*F///////////////////////////////////////////////////////////////////////////////////////
 //    <Name>:    cvFindNextContour
 //    Purpose: finds next contour on the image
 //    Context:
 //    Parameters:
 //         scanner - contour scanner state
 //    Returns:
 //      next contour or NULL, if no more contours on the image
 //F*/
 OPENCVAPI  CvSeq*  cvFindNextContour( CvContourScanner scanner );


8.4.2.11.3. (cvSubstituteContour scanner ncontour)
(packages/opencv/contours.lsh)


 /*F///////////////////////////////////////////////////////////////////////////////////////
 //    Name:    cvSubstituteContour
 //    Purpose: substitutes retrived contour with another one.
 //    Context:
 //    Parameters:
 //         scanner - contour scanner state
 //         newContour - substituting contour
 //                      (or NULL, if retrived contour should be rejected)
 //    Returns:
 //    Notes:
 //      The function may be called immediately after contour is retrived
 //     (may be, after some processing) before cvFindNextContour is called next time.
 //      It replaces found contour with processed contour, or even rejects it.
 //F*/
 OPENCVAPI  void   cvSubstituteContour( CvContourScanner scanner, CvSeq* newContour );


8.4.2.11.4. (cvEndFindContours scanner)
(packages/opencv/contours.lsh)


 /*F///////////////////////////////////////////////////////////////////////////////////////
 //    Name:    cvEndFindContours
 //    Purpose: finishes process of contours retrieving
 //    Context:
 //    Parameters:
 //         scanner - contour scanner state
 //    Returns:
 //      pointer to first contour on the highest hierarchical level
 //F*/
 OPENCVAPI  CvSeq*  cvEndFindContours( CvContourScanner* scanner );


8.4.2.11.5. (cvApproxChains src_seq stor method parameter minimal_perimeter recursive)
(packages/opencv/contours.lsh)


 /*F///////////////////////////////////////////////////////////////////////////////////////
 //    Name:    cvApproxChains
 //    Purpose: approximates single(all) chains with polylines.
 //    Context:
 //    Parameters:
 //         src_seq - pointer to chain(which can reffer to other chains).
 //         storage - where to place resultant polylines.
 //         dst_seq - double pointer to first resultant polyline.
 //         method  - approximation method(see cvFindContours description)
 //         parameter - method parameter(is not used now).
 //         minimal_perimeter - approximates only those contours which perimeter is
 //                             not less than <minimal_perimeter>. Other chains
 //                             are removed from resultant structure
 //         recursive - if not 0, approximate all the chains, which can be accessed
 //                     from src_seq. if 0, approximate a single chain
 //    Returns:
 //F*/
 OPENCVAPI  CvSeq* cvApproxChains( CvSeq* src_seq, CvMemStorage* storage,
                             CvChainApproxMethod method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE),
                             double parameter CV_DEFAULT(0),
                             int  minimal_perimeter CV_DEFAULT(0),
                             int  recursive CV_DEFAULT(0));


8.4.2.11.6. (cvStartReadChainPoints chain reader)
(packages/opencv/contours.lsh)


 /*F///////////////////////////////////////////////////////////////////////////////////////
 //    Name:    cvStartReadChainPoints
 //    Purpose: starts read successive points of the chain-coded curve
 //    Context:
 //    Parameters:
 //         chain   - chain
 //         reader  - chain reader state
 //    Returns:
 //F*/
 OPENCVAPI  void  cvStartReadChainPoints( CvChain* chain, CvChainPtReader* reader );


8.4.2.11.7. (cvReadChainPoint reader pt)
(packages/opencv/contours.lsh)


 /*F///////////////////////////////////////////////////////////////////////////////////////
 //    Name:    cvReadChainPoint
 //    Purpose: read current point of the chain and moves read position to the next code
 //    Context:
 //    Parameters:
 //         reader - chain reader state
 //    Returns:
 //         current point of the chain
 //F*/
 OPENCVAPI  CvPoint   cvReadChainPoint( CvChainPtReader* reader );


8.4.2.11.8. (cvApproxPoly src_seq hsize stor method parameter recursive)
(packages/opencv/contours.lsh)


 /*F///////////////////////////////////////////////////////////////////////////////////////
 //    Name:    cvApproxPoly
 //    Purpose: approximates polygonal curve (either closed or not)
 //             with another polygonal curve with desired accuracy
 //    Context:
 //    Parameters:
 //         src_seq - source contour
 //         header_size - size of destination contour header
 //         storage - memory storage for result
 //         dst_seq - destination contour
 //         method  - approximation method. Only a single method is implemented now.
 //                   CV_POLY_APPROX_DP - Douglas-Peucker method.
 //         parameter - depends on method. For CV_POLY_APPROX_DP it is a desired accuracy.
 //         recursive - if not 0, the function approximates all the contours that
 //                     are next to or below the initial contour, otherwise the single
 //                     contour is approximated
 //    Returns:
 //F*/
 OPENCVAPI  CvSeq*  cvApproxPoly( CvSeq* src_seq, int  header_size, CvMemStorage* storage,
                                  CvPolyApproxMethod  method, double parameter,
                                  int recursive CV_DEFAULT(0));


8.4.2.11.9. (cvContourPerimeter contour)
(packages/opencv/contours.lsh)


 /*F///////////////////////////////////////////////////////////////////////////////////////
 //    Name:    cvContourPerimeter
 //    Purpose:
 //      Calculates contour perimeter, finds minimal edge and maximal egde lengths
 //    Context:
 //    Parameters:
 //      contour  - source contour
 //    Returns:
 //      contour section perimeter
 //      when a part of contour is selected, the function doesn't add
 //      length of chord, connecting starting and ending points
 //F*/
 OPENCVAPI  double  cvContourPerimeter( CvSeq* contour,
                                        CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ) );


8.4.2.11.10. (cvContourBoundingRect contour update rect)
(packages/opencv/contours.lsh)


 /*F///////////////////////////////////////////////////////////////////////////////////////
 //    Name:    cvContourBoundingRect
 //    Purpose:
 //      calculates contour bounding rebox
 //    Context:
 //    Parameters:
 //      contour  - pointer to the source contour
 //      update   - attribute of contour bounding box updating
 //                 (if update = 0 the bounding box isn't updated)
 //    Returns:
 //      bounding rectangle
 //F*/
 OPENCVAPI  CvRect  cvContourBoundingRect( CvSeq* contour, int update CV_DEFAULT(0) );


8.4.2.11.11. (cvContourMoments contour moments)
(packages/opencv/contours.lsh)


 /*F///////////////////////////////////////////////////////////////////////////////////////
 //    Name: cvContourMoments
 //    Purpose:
 //      Calculates spatial and central moments of the contour up to order 3
 //    Context:
 //    Parameters:
 //      contour - the source contour
 //      moments - output parameter. Pointer to the calculated moments
 //
 //F*/
 OPENCVAPI  void  cvContourMoments( CvSeq* contour, CvMoments* moments);


8.4.2.11.12. (cvContourArea contour slice)
(packages/opencv/contours.lsh)


 /*F///////////////////////////////////////////////////////////////////////////////////////
 //    Name: cvContourArea
 //    Purpose:
 //      Calculates area within the contour
 //    Context:
 //    Parameters:
 //      contour - pointer to input contour object.
 //      slice  - optional parameter. ending and starting indices of contour section  
 //    Returns:
 //      Contour section area
 //F*/
 OPENCVAPI  double  cvContourArea( CvSeq* contour,
                                CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ));


8.4.2.11.13. (cvMatchContours contour1 contour2 method parameter)
(packages/opencv/contours.lsh)


 /*F///////////////////////////////////////////////////////////////////////////////////////
 //    Name: cvMatchContours
 //    Purpose:
 //      Compares two contours
 //    Context:
 //    Parameters:
 //      contour1 - pointer to the first input contour object.
 //      contour2 - pointer to the second input contour object.
 //      method - method for the matching calculation
 //     (now CV_CONTOURS_MATCH_I1, CV_CONTOURS_MATCH_I2 or
 //      CV_CONTOURS_MATCH_I3 only  )
 //      parameter - method-specific parameter (is used now)
 //    Returns:
 //      Comparison result
 //F*/
 OPENCVAPI  double  cvMatchContours( CvSeq* contour1, CvSeq* contour2,
                                  CvContoursMatchMethod method,
                                  long parameter CV_DEFAULT(0));


8.4.2.11.14. (cvCreateContourTree contour stor threshold)
(packages/opencv/contours.lsh)


 /*F///////////////////////////////////////////////////////////////////////////////////////
 //    Name: cvCreateContourTree
 //    Purpose:
 //      Creates binary tree representation for the contour
 //    Context:
 //    Parameters:
 //      contour - input contour
 //      storage - storage
 //      tree    - output pointer to the binary tree representation
 //      threshold - threshold for the binary tree building
 //    Returns:
 //      Binary tree
 //F*/
 typedef struct CvContourTree
 {
     CV_SEQUENCE_FIELDS()
     CvPoint p1;            /* the first point of the binary tree root segment */
     CvPoint p2;            /* the last point of the binary tree root segment */
 } CvContourTree;
 OPENCVAPI  CvContourTree*   cvCreateContourTree( CvSeq* contour, CvMemStorage* storage,
                                                  double threshold );


8.4.2.11.15. (cvContourFromContourTree tree stor criteria)
(packages/opencv/contours.lsh)


 /*F///////////////////////////////////////////////////////////////////////////////////////
 //    Name: cvContourFromContourTree
 //    Purpose:
 //      Reconstructs contour from binary tree representation
 //    Context:
 //    Parameters:
 //      tree   -  input binary tree representation
 //      storage - memory storage
 //      criteria - criteria for the definition threshold value
 //                 for the contour reconstruction(level or precision)
 //    Returns:
 //      Created contour
 //F*/
 OPENCVAPI  CvSeq*  cvContourFromContourTree( CvContourTree *tree,
                                           CvMemStorage* storage,
                                           CvTermCriteria criteria );


8.4.2.11.16. (cvMatchContourTrees tree1 tree2 method threshold)
(packages/opencv/contours.lsh)


 /*F///////////////////////////////////////////////////////////////////////////////////////
 //    Name: cvMatchContourTrees
 //    Purpose:
 //      Compares two contour trees
 //    Context:
 //    Parameters:
 //      tree1 - pointer to the first input contour tree object.
 //      tree2 - pointer to the second input contour tree object.
 //      method - method for the matching calculation
 //     (now CV_CONTOUR_TREES_MATCH_I1 only  )
 //      threshold - threshold for the contour trees matching
 //    Returns:
 //      comparison result
 //F*/
 OPENCVAPI  double  cvMatchContourTrees( CvContourTree *tree1,
                                      CvContourTree *tree2,
                                      CvContourTreesMatchMethod method,
                                      double threshold );


8.4.2.11.17. (cvDrawContours img contour excolor hcolor maxlevel thickness connectivity offset)
(packages/opencv/contours.lsh)


 /*F///////////////////////////////////////////////////////////////////////////////////////
 //    Name: cvDrawContours
 //    Purpose:
 //      Draws one or more contours outlines or their interiors on the image
 //    Context:
 //    Parameters:
 //      img      - destination three-channel image
 //      contour  - pointer to drawn contour(s).
 //      external_color - color to draw external contours with (CvScalar object)
 //      hole_color - color to draw hole contours with (CvScalar object)
 //      max_level  - max level of the tree(starting from contour pointer) to draw.
 //                   if it is 0, draw single contour, if 1 - draw the contour and
 //                   other contours at the same level, 2 - draw two levels etc.
 //      thickness - thickness of lines the contours are drawn with. If it is
 //                  equal to CV_FILLED (-1), the contour(s) interior is filled.
 //      line_type - (an int)
 //      offset    - (a CvPoint object)
 //    Returns:
 //F*/
 CVAPI void  cvDrawContours(CvArr *img, CvSeq* contour,
                                 CvScalar external_color, CvScalar double hole_color,
                                 int max_level, int thickness CV_DEFAULT(1),
                                 int line_type CV_DEFAULT(8),
                                 CvPoint offset CV_DEFAULT(cvPoint(0,0));


8.4.2.11.18. (cvCalcPGH contour hist)
(packages/opencv/contours.lsh)


 /*F///////////////////////////////////////////////////////////////////////////////////////
 //    Name: cvCalcPGH
 //    Purpose:
 //      Calculates PGH(pairwise geometric histogram) for given contour.
 //    Context:
 //    Parameters:
 //      contour  - input contour.
 //      pgh      - output histogram(must be two-dimensional)
 //    Returns:
 //F*/
 OPENCVAPI  void  cvCalcPGH( CvSeq* contour, CvHistogram* hist );