Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CheckerboardDetector.hh
1 /*
2  This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4  Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10  BIAS is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation; either version 2.1 of the License, or
13  (at your option) any later version.
14 
15  BIAS is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with BIAS; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  */
24 
25 #ifndef __CheckerboardDetector_hh__
26 #define __CheckerboardDetector_hh__
27 
28 //#include <cv.h>
29 
30 #include <bias_config.h>
31 #ifndef BIAS_HAVE_OPENCV
32 # error Please recompile BIAS with USE_OPENCV to use this code.
33 #endif
34 
35 #include <Base/Image/ImageBase.hh>
36 #include <vector>
37 
38 
39 namespace BIAS {
40 
41  /// helper vector of coordinates
42  typedef std::vector< std::pair<float,float> > t_CoordVecf;
43 
44  /**
45  @class CheckerboardDetector
46  @brief Detects a checkerboard pattern in an image (typically 7x4 inner
47  corners, asymmetric layout recommended).
48  @note Based on OpenCV implementation.
49  @author Jan Woetzel
50  @date 2006
51  @ingroup g_feature
52  */
53  class BIASFeatureDetector_EXPORT CheckerboardDetector {
54 
55  public:
56 
57  /** @brief Detects a (recommended asymmetric) checkerboard pattern.
58  @return 0 for success,
59  <0 for error (e.g. could not detect all inner corners).
60  */
61  static int Compute(const BIAS::Image<unsigned char> &img,
62  const unsigned int &xCorners,
63  const unsigned int & yCorners,
64  t_CoordVecf &coords,
65  const bool &saveDebugImage = false);
66 
67  /** @brief Takes number of inner corners on x axis and y axis,
68  and number of images to build an array of corners,
69  and draws computed corners into CV image.
70  @note Assumes all corners to lie on z = 0 plane.
71  */
72  static void DrawPoints(void* img,
73  void* ptArray,
74  //t_CoordVecf & coords,
75  int numPts,
76  const int xCorners,
77  const int yCorners,
78  const bool DRAW_IDEAL_OVERLAY = true,
79  const bool DRAW_AXES = true,
80  const bool DRAW_POINT_LABEL = true);
81 
82  /* @brief Set flags for OpenCV checkerboard corner detection algorithm.
83  Valid flags are CV_CALIB_CB_ADAPTIVE_THRESH, CV_CALIB_CB_NORMALIZE_IMAGE,
84  CV_CALIB_CB_FILTER_QUADS or combinations of these flags.
85  */
86  static void SetCornerDetectorFlags(int flags) {
87  cornerDetectorFlags_ = flags;
88  };
89 
90  /* @brief Set max. number of iterations for subpixel corner refinement. */
91  static void SetSubPixelIterations(int maxIters) {
92  subPixelIterations_ = maxIters;
93  };
94 
95  /* @brief Set accuracy to achieve in subpixel corner refinement. */
96  static void SetSubPixelAccuracy(double accuracy) {
97  subPixelAccuracy_ = accuracy;
98  };
99 
100  private:
101 
102  // Flags for checkerboard corner detection algorithm (OpenCV)
103  static int cornerDetectorFlags_;
104 
105  // Max. number of iterations for subpixel corner refinement
106  static int subPixelIterations_;
107 
108  // Accuracy to achieve in subpixel corner refinement
109  static double subPixelAccuracy_;
110 
111  };
112 }
113 
114 #endif //__CheckerboardDetector_hh__
static void SetSubPixelIterations(int maxIters)
std::vector< std::pair< float, float > > t_CoordVecf
helper vector of coordinates
Detects a checkerboard pattern in an image (typically 7x4 inner corners, asymmetric layout recommende...
static void SetSubPixelAccuracy(double accuracy)
static void SetCornerDetectorFlags(int flags)