Main MRPT website > C++ reference for MRPT 1.5.5
checkerboard_ocamcalib_detector.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #ifndef INTERNAL_CHECKERBOARD_INCL_H
11 #define INTERNAL_CHECKERBOARD_INCL_H
12 
13 // Universal include for all versions of OpenCV
14 #include <mrpt/otherlibs/do_opencv_includes.h>
15 
16 #include <cmath>
17 #include <cstdio>
18 
19 #if MRPT_HAS_OPENCV
20 
21 // Debug visualizations...
22 //Ming #define VIS 1
23 #define VIS 0
24 
25 // Definition Contour Struct
27 {
28  CV_CONTOUR_FIELDS()
29  int counter;
30 };
31 
32 // Definition Corner Struct
33 struct CvCBCorner;
34 typedef stlplus::smart_ptr<CvCBCorner> CvCBCornerPtr;
35 
36 struct CvCBCorner
37 {
38  CvCBCorner() : row(-1000),column(-1000), count(0)
39  {}
40 
41  CvPoint2D32f pt; // X and y coordinates
42  int row; // Row and column of the corner
43  int column; // in the found pattern
44  bool needsNeighbor; // Does the corner require a neighbor?
45  int count; // number of corner neighbors
46  CvCBCornerPtr neighbors[4]; // pointer to all corner neighbors
47 };
48 
49 
50 // Definition Quadrangle Struct
51 // This structure stores information about the chessboard quadrange
52 struct CvCBQuad;
53 typedef stlplus::smart_ptr<CvCBQuad> CvCBQuadPtr;
54 
55 struct CvCBQuad
56 {
57  CvCBQuad() : count(0),group_idx(0),edge_len(0),labeled(false),area(0.0), area_ratio(1.0)
58  {}
59 
60  int count; // Number of quad neihbors
61  int group_idx; // Quad group ID
62  float edge_len; // Smallest side length^2
63  CvCBCornerPtr corners[4]; //CvCBCorner *corners[4]; // Coordinates of quad corners
64  CvCBQuadPtr neighbors[4]; // Pointers of quad neighbors
65  bool labeled; // Has this corner been labeled?
66  double area, area_ratio;
67 };
68 
69 
70 //===========================================================================
71 // PUBLIC FUNCTION PROTOTYPES
72 //===========================================================================
73 // Return: -1: errors, 0: not found, 1: found OK
75  const mrpt::utils::CImage & img_,
76  CvSize pattern_size,
77  std::vector<CvPoint2D32f> &out_corners);
78 
79 // Return: true: found OK
81  const mrpt::utils::CImage & img_,
82  CvSize pattern_size,
83  std::vector< std::vector<CvPoint2D32f> > &out_corners);
84 
85 
86 //===========================================================================
87 // INTERNAL FUNCTION PROTOTYPES
88 //===========================================================================
89 int icvGenerateQuads( std::vector<CvCBQuadPtr> &quads, std::vector<CvCBCornerPtr> &corners,
90  const mrpt::utils::CImage &img, int flags, int dilation,
91  bool firstRun );
92 
93 void mrFindQuadNeighbors2( std::vector<CvCBQuadPtr> &quads, int dilation);
94 
95 int mrAugmentBestRun( std::vector<CvCBQuadPtr> &new_quads, int new_dilation,
96  std::vector<CvCBQuadPtr> &old_quads, int old_dilation );
97 
99  std::vector<CvCBQuadPtr> &in_quads,
100  std::vector<CvCBQuadPtr> &out_quad_group,
101  const int group_idx,
102  const int dilation );
103 
104 void mrLabelQuadGroup( std::vector<CvCBQuadPtr> &quad_group, const CvSize &pattern_size, bool firstRun );
105 
106 // Remove quads' extra quads until reached the expected number of quads.
107 void icvCleanFoundConnectedQuads( std::vector<CvCBQuadPtr> &quads, const CvSize &pattern_size );
108 
109 // JL: Return 1 on success in finding all the quads, 0 on didn't, -1 on error.
110 int myQuads2Points( const std::vector<CvCBQuadPtr> &output_quads, const CvSize &pattern_size, std::vector<CvPoint2D32f> &out_corners);
111 
112 // JL: Make unique all the (smart pointers-pointed) objects in the list and neighbors lists.
113 void quadListMakeUnique( std::vector<CvCBQuadPtr> &quads);
114 
115 // JL: Refactored code from within cvFindChessboardCorners3() and alternative algorithm:
116 bool do_special_dilation(mrpt::utils::CImage &thresh_img, const int dilations,
117  IplConvKernel *kernel_cross,
118  IplConvKernel *kernel_rect,
119  IplConvKernel *kernel_diag1,
120  IplConvKernel *kernel_diag2,
121  IplConvKernel *kernel_horz,
122  IplConvKernel *kernel_vert
123  );
124 
125 
126 #endif // MRPT_HAS_OPENCV
127 
128 #endif
129 
GLuint GLuint GLsizei count
Definition: glext.h:3512
int mrAugmentBestRun(std::vector< CvCBQuadPtr > &new_quads, int new_dilation, std::vector< CvCBQuadPtr > &old_quads, int old_dilation)
stlplus::smart_ptr< CvCBCorner > CvCBCornerPtr
stlplus::smart_ptr< CvCBQuad > CvCBQuadPtr
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:101
void quadListMakeUnique(std::vector< CvCBQuadPtr > &quads)
int cvFindChessboardCorners3(const mrpt::utils::CImage &img_, CvSize pattern_size, std::vector< CvPoint2D32f > &out_corners)
void icvCleanFoundConnectedQuads(std::vector< CvCBQuadPtr > &quads, const CvSize &pattern_size)
void mrLabelQuadGroup(std::vector< CvCBQuadPtr > &quad_group, const CvSize &pattern_size, bool firstRun)
bool find_chessboard_corners_multiple(const mrpt::utils::CImage &img_, CvSize pattern_size, std::vector< std::vector< CvPoint2D32f > > &out_corners)
GLint GLvoid * img
Definition: glext.h:3645
int myQuads2Points(const std::vector< CvCBQuadPtr > &output_quads, const CvSize &pattern_size, std::vector< CvPoint2D32f > &out_corners)
void mrFindQuadNeighbors2(std::vector< CvCBQuadPtr > &quads, int dilation)
int icvGenerateQuads(std::vector< CvCBQuadPtr > &quads, std::vector< CvCBCornerPtr > &corners, const mrpt::utils::CImage &img, int flags, int dilation, bool firstRun)
GLenum GLenum GLvoid * row
Definition: glext.h:3533
bool do_special_dilation(mrpt::utils::CImage &thresh_img, const int dilations, IplConvKernel *kernel_cross, IplConvKernel *kernel_rect, IplConvKernel *kernel_diag1, IplConvKernel *kernel_diag2, IplConvKernel *kernel_horz, IplConvKernel *kernel_vert)
void icvFindConnectedQuads(std::vector< CvCBQuadPtr > &in_quads, std::vector< CvCBQuadPtr > &out_quad_group, const int group_idx, const int dilation)
GLenum GLenum GLvoid GLvoid * column
Definition: glext.h:3533



Page generated by Doxygen 1.8.14 for MRPT 1.5.5 Git: e06b63dbf Fri Dec 1 14:41:11 2017 +0100 at lun oct 28 01:31:35 CET 2019