Main MRPT website > C++ reference for MRPT 1.5.7
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 #include <memory>
19 
20 
21 #if MRPT_HAS_OPENCV
22 
23 // Debug visualizations...
24 //Ming #define VIS 1
25 #define VIS 0
26 
27 // Definition Contour Struct
29 {
30  CV_CONTOUR_FIELDS()
31  int counter;
32 };
33 
34 // Definition Corner Struct
35 struct CvCBCorner;
36 typedef std::shared_ptr<CvCBCorner> CvCBCornerPtr;
37 
38 struct CvCBCorner
39 {
40  CvCBCorner() : row(-1000),column(-1000), count(0)
41  {}
42 
43  CvPoint2D32f pt; // X and y coordinates
44  int row; // Row and column of the corner
45  int column; // in the found pattern
46  bool needsNeighbor; // Does the corner require a neighbor?
47  int count; // number of corner neighbors
48  CvCBCornerPtr neighbors[4]; // pointer to all corner neighbors
49 };
50 
51 
52 // Definition Quadrangle Struct
53 // This structure stores information about the chessboard quadrange
54 struct CvCBQuad;
55 typedef std::shared_ptr<CvCBQuad> CvCBQuadPtr;
56 
57 struct CvCBQuad
58 {
59  CvCBQuad() : count(0),group_idx(0),edge_len(0),labeled(false),area(0.0), area_ratio(1.0)
60  {}
61 
62  int count; // Number of quad neihbors
63  int group_idx; // Quad group ID
64  float edge_len; // Smallest side length^2
65  CvCBCornerPtr corners[4]; //CvCBCorner *corners[4]; // Coordinates of quad corners
66  CvCBQuadPtr neighbors[4]; // Pointers of quad neighbors
67  bool labeled; // Has this corner been labeled?
68  double area, area_ratio;
69 };
70 
71 
72 //===========================================================================
73 // PUBLIC FUNCTION PROTOTYPES
74 //===========================================================================
75 // Return: -1: errors, 0: not found, 1: found OK
77  const mrpt::utils::CImage & img_,
78  CvSize pattern_size,
79  std::vector<CvPoint2D32f> &out_corners);
80 
81 // Return: true: found OK
83  const mrpt::utils::CImage & img_,
84  CvSize pattern_size,
85  std::vector< std::vector<CvPoint2D32f> > &out_corners);
86 
87 
88 //===========================================================================
89 // INTERNAL FUNCTION PROTOTYPES
90 //===========================================================================
91 int icvGenerateQuads( std::vector<CvCBQuadPtr> &quads, std::vector<CvCBCornerPtr> &corners,
92  const mrpt::utils::CImage &img, int flags, int dilation,
93  bool firstRun );
94 
95 void mrFindQuadNeighbors2( std::vector<CvCBQuadPtr> &quads, int dilation);
96 
97 int mrAugmentBestRun( std::vector<CvCBQuadPtr> &new_quads, int new_dilation,
98  std::vector<CvCBQuadPtr> &old_quads, int old_dilation );
99 
101  std::vector<CvCBQuadPtr> &in_quads,
102  std::vector<CvCBQuadPtr> &out_quad_group,
103  const int group_idx,
104  const int dilation );
105 
106 void mrLabelQuadGroup( std::vector<CvCBQuadPtr> &quad_group, const CvSize &pattern_size, bool firstRun );
107 
108 // Remove quads' extra quads until reached the expected number of quads.
109 void icvCleanFoundConnectedQuads( std::vector<CvCBQuadPtr> &quads, const CvSize &pattern_size );
110 
111 // JL: Return 1 on success in finding all the quads, 0 on didn't, -1 on error.
112 int myQuads2Points( const std::vector<CvCBQuadPtr> &output_quads, const CvSize &pattern_size, std::vector<CvPoint2D32f> &out_corners);
113 
114 // JL: Make unique all the (smart pointers-pointed) objects in the list and neighbors lists.
115 void quadListMakeUnique( std::vector<CvCBQuadPtr> &quads);
116 
117 // JL: Refactored code from within cvFindChessboardCorners3() and alternative algorithm:
118 bool do_special_dilation(mrpt::utils::CImage &thresh_img, const int dilations,
119  IplConvKernel *kernel_cross,
120  IplConvKernel *kernel_rect,
121  IplConvKernel *kernel_diag1,
122  IplConvKernel *kernel_diag2,
123  IplConvKernel *kernel_horz,
124  IplConvKernel *kernel_vert
125  );
126 
127 
128 #endif // MRPT_HAS_OPENCV
129 
130 #endif
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)
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)
STL namespace.
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)
std::shared_ptr< CvCBCorner > CvCBCornerPtr
GLenum GLenum GLvoid GLvoid * column
Definition: glext.h:3533
std::shared_ptr< CvCBQuad > CvCBQuadPtr



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019