Main MRPT website > C++ reference for MRPT 1.9.9
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-2018, 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 #include <memory>
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 
37 struct CvCBCorner
38 {
40  CvCBCorner() : row(-1000), column(-1000), count(0) {}
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  CvCBCorner::Ptr neighbors[4]; // pointer to all corner neighbors
47 };
48 
49 // Definition Quadrangle Struct
50 // This structure stores information about the chessboard quadrange
51 struct CvCBQuad;
52 
53 struct CvCBQuad
54 {
57  : count(0),
58  group_idx(0),
59  edge_len(0),
60  labeled(false),
61  area(0.0),
62  area_ratio(1.0)
63  {
64  }
65 
66  int count; // Number of quad neihbors
67  int group_idx; // Quad group ID
68  float edge_len; // Smallest side length^2
69  CvCBCorner::Ptr corners[4]; // CvCBCorner *corners[4]; //
70  // Coordinates of quad corners
71  CvCBQuad::Ptr neighbors[4]; // Pointers of quad neighbors
72  bool labeled; // Has this corner been labeled?
73  double area, area_ratio;
74 };
75 
76 //===========================================================================
77 // PUBLIC FUNCTION PROTOTYPES
78 //===========================================================================
79 // Return: -1: errors, 0: not found, 1: found OK
81  const mrpt::img::CImage& img_, CvSize pattern_size,
82  std::vector<CvPoint2D32f>& out_corners);
83 
84 // Return: true: found OK
86  const mrpt::img::CImage& img_, CvSize pattern_size,
87  std::vector<std::vector<CvPoint2D32f>>& out_corners);
88 
89 //===========================================================================
90 // INTERNAL FUNCTION PROTOTYPES
91 //===========================================================================
93  std::vector<CvCBQuad::Ptr>& quads, std::vector<CvCBCorner::Ptr>& corners,
94  const mrpt::img::CImage& img, int flags, int dilation, bool firstRun);
95 
96 void mrFindQuadNeighbors2(std::vector<CvCBQuad::Ptr>& quads, int dilation);
97 
99  std::vector<CvCBQuad::Ptr>& new_quads, int new_dilation,
100  std::vector<CvCBQuad::Ptr>& old_quads, int old_dilation);
101 
103  std::vector<CvCBQuad::Ptr>& in_quads,
104  std::vector<CvCBQuad::Ptr>& out_quad_group, const int group_idx,
105  const int dilation);
106 
107 void mrLabelQuadGroup(
108  std::vector<CvCBQuad::Ptr>& quad_group, const CvSize& pattern_size,
109  bool firstRun);
110 
111 // Remove quads' extra quads until reached the expected number of quads.
113  std::vector<CvCBQuad::Ptr>& quads, const CvSize& pattern_size);
114 
115 // JL: Return 1 on success in finding all the quads, 0 on didn't, -1 on error.
116 int myQuads2Points(
117  const std::vector<CvCBQuad::Ptr>& output_quads, const CvSize& pattern_size,
118  std::vector<CvPoint2D32f>& out_corners);
119 
120 // JL: Make unique all the (smart pointers-pointed) objects in the list and
121 // neighbors lists.
122 void quadListMakeUnique(std::vector<CvCBQuad::Ptr>& quads);
123 
124 // JL: Refactored code from within cvFindChessboardCorners3() and alternative
125 // algorithm:
127  mrpt::img::CImage& thresh_img, const int dilations,
128  IplConvKernel* kernel_cross, IplConvKernel* kernel_rect,
129  IplConvKernel* kernel_diag1, IplConvKernel* kernel_diag2,
130  IplConvKernel* kernel_horz, IplConvKernel* kernel_vert);
131 
132 #endif // MRPT_HAS_OPENCV
133 
134 #endif
GLuint GLuint GLsizei count
Definition: glext.h:3528
void mrLabelQuadGroup(std::vector< CvCBQuad::Ptr > &quad_group, const CvSize &pattern_size, bool firstRun)
void quadListMakeUnique(std::vector< CvCBQuad::Ptr > &quads)
int myQuads2Points(const std::vector< CvCBQuad::Ptr > &output_quads, const CvSize &pattern_size, std::vector< CvPoint2D32f > &out_corners)
int cvFindChessboardCorners3(const mrpt::img::CImage &img_, CvSize pattern_size, std::vector< CvPoint2D32f > &out_corners)
bool do_special_dilation(mrpt::img::CImage &thresh_img, const int dilations, IplConvKernel *kernel_cross, IplConvKernel *kernel_rect, IplConvKernel *kernel_diag1, IplConvKernel *kernel_diag2, IplConvKernel *kernel_horz, IplConvKernel *kernel_vert)
int icvGenerateQuads(std::vector< CvCBQuad::Ptr > &quads, std::vector< CvCBCorner::Ptr > &corners, const mrpt::img::CImage &img, int flags, int dilation, bool firstRun)
GLint GLvoid * img
Definition: glext.h:3763
void icvCleanFoundConnectedQuads(std::vector< CvCBQuad::Ptr > &quads, const CvSize &pattern_size)
GLenum GLenum GLvoid * row
Definition: glext.h:3576
int mrAugmentBestRun(std::vector< CvCBQuad::Ptr > &new_quads, int new_dilation, std::vector< CvCBQuad::Ptr > &old_quads, int old_dilation)
bool find_chessboard_corners_multiple(const mrpt::img::CImage &img_, CvSize pattern_size, std::vector< std::vector< CvPoint2D32f >> &out_corners)
GLenum GLenum GLvoid GLvoid * column
Definition: glext.h:3576
void icvFindConnectedQuads(std::vector< CvCBQuad::Ptr > &in_quads, std::vector< CvCBQuad::Ptr > &out_quad_group, const int group_idx, const int dilation)
void mrFindQuadNeighbors2(std::vector< CvCBQuad::Ptr > &quads, int dilation)
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:130



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019