Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/calib3d/src/chessboard.hpp
16354 views
1
// This file is part of OpenCV project.
2
// It is subject to the license terms in the LICENSE file found in the top-level directory
3
// of this distribution and at http://opencv.org/license.html.
4
5
#ifndef CHESSBOARD_HPP_
6
#define CHESSBOARD_HPP_
7
8
#include "opencv2/core.hpp"
9
#include "opencv2/features2d.hpp"
10
#include <vector>
11
#include <set>
12
#include <map>
13
14
namespace cv {
15
namespace details{
16
/**
17
* \brief Fast point sysmetric cross detector based on a localized radon transformation
18
*/
19
class FastX : public cv::Feature2D
20
{
21
public:
22
struct Parameters
23
{
24
float strength; //!< minimal strength of a valid junction in dB
25
float resolution; //!< angle resolution in radians
26
int branches; //!< the number of branches
27
int min_scale; //!< scale level [0..8]
28
int max_scale; //!< scale level [0..8]
29
bool filter; //!< post filter feature map to improve impulse response
30
bool super_resolution; //!< up-sample
31
32
Parameters()
33
{
34
strength = 40;
35
resolution = float(CV_PI*0.25);
36
branches = 2;
37
min_scale = 2;
38
max_scale = 5;
39
super_resolution = 1;
40
filter = true;
41
}
42
};
43
44
public:
45
FastX(const Parameters &config = Parameters());
46
virtual ~FastX(){};
47
48
void reconfigure(const Parameters &para);
49
50
//declaration to be wrapped by rbind
51
void detect(cv::InputArray image,std::vector<cv::KeyPoint>& keypoints, cv::InputArray mask=cv::Mat())override
52
{cv::Feature2D::detect(image.getMat(),keypoints,mask.getMat());}
53
54
virtual void detectAndCompute(cv::InputArray image,
55
cv::InputArray mask,
56
std::vector<cv::KeyPoint>& keypoints,
57
cv::OutputArray descriptors,
58
bool useProvidedKeyPoints = false)override;
59
60
void detectImpl(const cv::Mat& image,
61
std::vector<cv::KeyPoint>& keypoints,
62
std::vector<cv::Mat> &feature_maps,
63
const cv::Mat& mask=cv::Mat())const;
64
65
void detectImpl(const cv::Mat& image,
66
std::vector<cv::Mat> &rotated_images,
67
std::vector<cv::Mat> &feature_maps,
68
const cv::Mat& mask=cv::Mat())const;
69
70
void findKeyPoints(const std::vector<cv::Mat> &feature_map,
71
std::vector<cv::KeyPoint>& keypoints,
72
const cv::Mat& mask = cv::Mat())const;
73
74
std::vector<std::vector<float> > calcAngles(const std::vector<cv::Mat> &rotated_images,
75
std::vector<cv::KeyPoint> &keypoints)const;
76
// define pure virtual methods
77
virtual int descriptorSize()const override{return 0;};
78
virtual int descriptorType()const override{return 0;};
79
virtual void operator()( cv::InputArray image, cv::InputArray mask, std::vector<cv::KeyPoint>& keypoints, cv::OutputArray descriptors, bool useProvidedKeypoints=false )const
80
{
81
descriptors.clear();
82
detectImpl(image.getMat(),keypoints,mask);
83
if(!useProvidedKeypoints) // suppress compiler warning
84
return;
85
return;
86
}
87
88
protected:
89
virtual void computeImpl( const cv::Mat& image, std::vector<cv::KeyPoint>& keypoints, cv::Mat& descriptors)const
90
{
91
descriptors = cv::Mat();
92
detectImpl(image,keypoints);
93
}
94
95
private:
96
void detectImpl(const cv::Mat& _src, std::vector<cv::KeyPoint>& keypoints, const cv::Mat& mask)const;
97
virtual void detectImpl(cv::InputArray image, std::vector<cv::KeyPoint>& keypoints, cv::InputArray mask=cv::noArray())const;
98
99
void rotate(float angle,const cv::Mat &img,cv::Size size,cv::Mat &out)const;
100
void calcFeatureMap(const cv::Mat &images,cv::Mat& out)const;
101
102
private:
103
Parameters parameters;
104
};
105
106
/**
107
* \brief Ellipse class
108
*/
109
class Ellipse
110
{
111
public:
112
Ellipse();
113
Ellipse(const cv::Point2f &center, const cv::Size2f &axes, float angle);
114
Ellipse(const Ellipse &other);
115
116
117
void draw(cv::InputOutputArray img,const cv::Scalar &color = cv::Scalar::all(120))const;
118
bool contains(const cv::Point2f &pt)const;
119
cv::Point2f getCenter()const;
120
const cv::Size2f &getAxes()const;
121
122
private:
123
cv::Point2f center;
124
cv::Size2f axes;
125
float angle,cosf,sinf;
126
};
127
128
/**
129
* \brief Chessboard corner detector
130
*
131
* The detectors tries to find all chessboard corners of an imaged
132
* chessboard and returns them as an ordered vector of KeyPoints.
133
* Thereby, the left top corner has index 0 and the bottom right
134
* corner n*m-1.
135
*/
136
class Chessboard: public cv::Feature2D
137
{
138
public:
139
static const int DUMMY_FIELD_SIZE = 100; // in pixel
140
141
/**
142
* \brief Configuration of a chessboard corner detector
143
*
144
*/
145
struct Parameters
146
{
147
cv::Size chessboard_size; //!< size of the chessboard
148
int min_scale; //!< scale level [0..8]
149
int max_scale; //!< scale level [0..8]
150
int max_points; //!< maximal number of points regarded
151
int max_tests; //!< maximal number of tested hypothesis
152
bool super_resolution; //!< use super-repsolution for chessboard detection
153
bool larger; //!< indicates if larger boards should be returned
154
155
Parameters()
156
{
157
chessboard_size = cv::Size(9,6);
158
min_scale = 2;
159
max_scale = 4;
160
super_resolution = true;
161
max_points = 400;
162
max_tests = 100;
163
larger = false;
164
}
165
166
Parameters(int scale,int _max_points):
167
min_scale(scale),
168
max_scale(scale),
169
max_points(_max_points)
170
{
171
chessboard_size = cv::Size(9,6);
172
}
173
};
174
175
176
/**
177
* \brief Gets the 3D objects points for the chessboard assuming the
178
* left top corner is located at the origin.
179
*
180
* \param[in] pattern_size Number of rows and cols of the pattern
181
* \param[in] cell_size Size of one cell
182
*
183
* \returns Returns the object points as CV_32FC3
184
*/
185
static cv::Mat getObjectPoints(const cv::Size &pattern_size,float cell_size);
186
187
/**
188
* \brief Class for searching and storing chessboard corners.
189
*
190
* The search is based on a feature map having strong pixel
191
* values at positions where a chessboard corner is located.
192
*
193
* The board must be rectangular but supports empty cells
194
*
195
*/
196
class Board
197
{
198
public:
199
/**
200
* \brief Estimates the position of the next point on a line using cross ratio constrain
201
*
202
* cross ratio:
203
* d12/d34 = d13/d24
204
*
205
* point order on the line:
206
* pt1 --> pt2 --> pt3 --> pt4
207
*
208
* \param[in] pt1 First point coordinate
209
* \param[in] pt2 Second point coordinate
210
* \param[in] pt3 Third point coordinate
211
* \param[out] pt4 Forth point coordinate
212
*
213
*/
214
static bool estimatePoint(const cv::Point2f &p0,const cv::Point2f &p1,const cv::Point2f &p2,cv::Point2f &p3);
215
216
// using 1D homography
217
static bool estimatePoint(const cv::Point2f &p0,const cv::Point2f &p1,const cv::Point2f &p2,const cv::Point2f &p3, cv::Point2f &p4);
218
219
/**
220
* \brief Checks if all points of a row or column have a valid cross ratio constraint
221
*
222
* cross ratio:
223
* d12/d34 = d13/d24
224
*
225
* point order on the row/column:
226
* pt1 --> pt2 --> pt3 --> pt4
227
*
228
* \param[in] points THe points of the row/column
229
*
230
*/
231
static bool checkRowColumn(const std::vector<cv::Point2f> &points);
232
233
/**
234
* \brief Estimates the search area for the next point on the line using cross ratio
235
*
236
* point order on the line:
237
* (p0) --> p1 --> p2 --> p3 --> search area
238
*
239
* \param[in] p1 First point coordinate
240
* \param[in] p2 Second point coordinate
241
* \param[in] p3 Third point coordinate
242
* \param[in] p Percentage of d34 used for the search area width and height [0..1]
243
* \param[out] ellipse The search area
244
* \param[in] p0 optional point to improve accuracy
245
*
246
* \return Returns false if no search area can be calculated
247
*
248
*/
249
static bool estimateSearchArea(const cv::Point2f &p1,const cv::Point2f &p2,const cv::Point2f &p3,float p,
250
Ellipse &ellipse,const cv::Point2f *p0 =NULL);
251
252
/**
253
* \brief Estimates the search area for a specific point based on the given homography
254
*
255
* \param[in] H homography descriping the transformation from ideal board to real one
256
* \param[in] row Row of the point
257
* \param[in] col Col of the point
258
* \param[in] p Percentage [0..1]
259
*
260
* \return Returns false if no search area can be calculated
261
*
262
*/
263
static Ellipse estimateSearchArea(cv::Mat H,int row, int col,float p,int field_size = DUMMY_FIELD_SIZE);
264
265
/**
266
* \brief Searches for the maximum in a given search area
267
*
268
* \param[in] map feature map
269
* \param[in] ellipse search area
270
* \param[in] min_val Minimum value of the maximum to be accepted as maximum
271
*
272
* \return Returns a negative value if all points are outside the ellipse
273
*
274
*/
275
static float findMaxPoint(cv::flann::Index &index,const cv::Mat &data,const Ellipse &ellipse,float white_angle,float black_angle,cv::Point2f &pt);
276
277
/**
278
* \brief Searches for the next point using cross ratio constrain
279
*
280
* \param[in] index flann index
281
* \param[in] data extended flann data
282
* \param[in] pt1
283
* \param[in] pt2
284
* \param[in] pt3
285
* \param[in] white_angle
286
* \param[in] black_angle
287
* \param[in] min_response
288
* \param[out] point The resulting point
289
*
290
* \return Returns false if no point could be found
291
*
292
*/
293
static bool findNextPoint(cv::flann::Index &index,const cv::Mat &data,
294
const cv::Point2f &pt1,const cv::Point2f &pt2, const cv::Point2f &pt3,
295
float white_angle,float black_angle,float min_response,cv::Point2f &point);
296
297
/**
298
* \brief Creates a new Board object
299
*
300
*/
301
Board(float white_angle=0,float black_angle=0);
302
Board(const cv::Size &size, const std::vector<cv::Point2f> &points,float white_angle=0,float black_angle=0);
303
Board(const Chessboard::Board &other);
304
virtual ~Board();
305
306
Board& operator=(const Chessboard::Board &other);
307
308
/**
309
* \brief Draws the corners into the given image
310
*
311
* \param[in] m The image
312
* \param[out] m The resulting image
313
* \param[in] H optional homography to calculate search area
314
*
315
*/
316
void draw(cv::InputArray m,cv::OutputArray out,cv::InputArray H=cv::Mat())const;
317
318
/**
319
* \brief Estimates the pose of the chessboard
320
*
321
*/
322
bool estimatePose(const cv::Size2f &real_size,cv::InputArray _K,cv::OutputArray rvec,cv::OutputArray tvec)const;
323
324
/**
325
* \brief Clears all internal data of the object
326
*
327
*/
328
void clear();
329
330
/**
331
* \brief Returns the angle of the black diagnonale
332
*
333
*/
334
float getBlackAngle()const;
335
336
/**
337
* \brief Returns the angle of the black diagnonale
338
*
339
*/
340
float getWhiteAngle()const;
341
342
/**
343
* \brief Initializes a 3x3 grid from 9 corner coordinates
344
*
345
* All points must be ordered:
346
* p0 p1 p2
347
* p3 p4 p5
348
* p6 p7 p8
349
*
350
* \param[in] points vector of points
351
*
352
* \return Returns false if the grid could not be initialized
353
*/
354
bool init(const std::vector<cv::Point2f> points);
355
356
/**
357
* \brief Returns true if the board is empty
358
*
359
*/
360
bool isEmpty() const;
361
362
/**
363
* \brief Returns all board corners as ordered vector
364
*
365
* The left top corner has index 0 and the bottom right
366
* corner rows*cols-1. All corners which only belong to
367
* empty cells are returned as NaN.
368
*/
369
std::vector<cv::Point2f> getCorners(bool ball=true) const;
370
371
/**
372
* \brief Returns all board corners as ordered vector of KeyPoints
373
*
374
* The left top corner has index 0 and the bottom right
375
* corner rows*cols-1.
376
*
377
* \param[in] ball if set to false only non empty points are returned
378
*
379
*/
380
std::vector<cv::KeyPoint> getKeyPoints(bool ball=true) const;
381
382
/**
383
* \brief Returns the centers of the chessboard cells
384
*
385
* The left top corner has index 0 and the bottom right
386
* corner (rows-1)*(cols-1)-1.
387
*
388
*/
389
std::vector<cv::Point2f> getCellCenters() const;
390
391
/**
392
* \brief Estimates the homography between an ideal board
393
* and reality based on the already recovered points
394
*
395
* \param[in] rect selecting a subset of the already recovered points
396
* \param[in] field_size The field size of the ideal board
397
*
398
*/
399
cv::Mat estimateHomography(cv::Rect rect,int field_size = DUMMY_FIELD_SIZE)const;
400
401
/**
402
* \brief Estimates the homography between an ideal board
403
* and reality based on the already recovered points
404
*
405
* \param[in] field_size The field size of the ideal board
406
*
407
*/
408
cv::Mat estimateHomography(int field_size = DUMMY_FIELD_SIZE)const;
409
410
/**
411
* \brief Returns the size of the board
412
*
413
*/
414
cv::Size getSize() const;
415
416
/**
417
* \brief Returns the number of cols
418
*
419
*/
420
size_t colCount() const;
421
422
/**
423
* \brief Returns the number of rows
424
*
425
*/
426
size_t rowCount() const;
427
428
/**
429
* \brief Returns the inner contour of the board inlcuding only valid corners
430
*
431
* \info the contour might be non squared if not all points of the board are defined
432
*
433
*/
434
std::vector<cv::Point2f> getContour()const;
435
436
437
/**
438
* \brief Grows the board in all direction until no more corners are found in the feature map
439
*
440
* \param[in] data CV_32FC1 data of the flann index
441
* \param[in] flann_index flann index
442
*
443
* \returns the number of grows
444
*/
445
int grow(const cv::Mat &data,cv::flann::Index &flann_index);
446
447
/**
448
* \brief Validates all corners using guided search based on the given homography
449
*
450
* \param[in] data CV_32FC1 data of the flann index
451
* \param[in] flann_index flann index
452
* \param[in] h Homography describing the transformation from ideal board to the real one
453
* \param[in] min_response Min response
454
*
455
* \returns the number of valid corners
456
*/
457
int validateCorners(const cv::Mat &data,cv::flann::Index &flann_index,const cv::Mat &h,float min_response=0);
458
459
/**
460
* \brief check that no corner is used more than once
461
*
462
* \returns Returns false if a corner is used more than once
463
*/
464
bool checkUnique()const;
465
466
/**
467
* \brief Returns false if the angles of the contour are smaller than 35°
468
*
469
*/
470
bool validateContour()const;
471
472
/**
473
* \brief Grows the board to the left by adding one column.
474
*
475
* \param[in] map CV_32FC1 feature map
476
*
477
* \returns Returns false if the feature map has no maxima at the requested positions
478
*/
479
bool growLeft(const cv::Mat &map,cv::flann::Index &flann_index);
480
void growLeft();
481
482
/**
483
* \brief Grows the board to the top by adding one row.
484
*
485
* \param[in] map CV_32FC1 feature map
486
*
487
* \returns Returns false if the feature map has no maxima at the requested positions
488
*/
489
bool growTop(const cv::Mat &map,cv::flann::Index &flann_index);
490
void growTop();
491
492
/**
493
* \brief Grows the board to the right by adding one column.
494
*
495
* \param[in] map CV_32FC1 feature map
496
*
497
* \returns Returns false if the feature map has no maxima at the requested positions
498
*/
499
bool growRight(const cv::Mat &map,cv::flann::Index &flann_index);
500
void growRight();
501
502
/**
503
* \brief Grows the board to the bottom by adding one row.
504
*
505
* \param[in] map CV_32FC1 feature map
506
*
507
* \returns Returns false if the feature map has no maxima at the requested positions
508
*/
509
bool growBottom(const cv::Mat &map,cv::flann::Index &flann_index);
510
void growBottom();
511
512
/**
513
* \brief Adds one column on the left side
514
*
515
* \param[in] points The corner coordinates
516
*
517
*/
518
void addColumnLeft(const std::vector<cv::Point2f> &points);
519
520
/**
521
* \brief Adds one column at the top
522
*
523
* \param[in] points The corner coordinates
524
*
525
*/
526
void addRowTop(const std::vector<cv::Point2f> &points);
527
528
/**
529
* \brief Adds one column on the right side
530
*
531
* \param[in] points The corner coordinates
532
*
533
*/
534
void addColumnRight(const std::vector<cv::Point2f> &points);
535
536
/**
537
* \brief Adds one row at the bottom
538
*
539
* \param[in] points The corner coordinates
540
*
541
*/
542
void addRowBottom(const std::vector<cv::Point2f> &points);
543
544
/**
545
* \brief Rotates the board 90° degrees to the left
546
*/
547
void rotateLeft();
548
549
/**
550
* \brief Rotates the board 90° degrees to the right
551
*/
552
void rotateRight();
553
554
/**
555
* \brief Flips the board along its local x(width) coordinate direction
556
*/
557
void flipVertical();
558
559
/**
560
* \brief Flips the board along its local y(height) coordinate direction
561
*/
562
void flipHorizontal();
563
564
/**
565
* \brief Flips and rotates the board so that the anlge of
566
* either the black or white diagonale is bigger than the x
567
* and y axis of the board and from a right handed
568
* coordinate system
569
*/
570
void normalizeOrientation(bool bblack=true);
571
572
/**
573
* \brief Exchanges the stored board with the board stored in other
574
*/
575
void swap(Chessboard::Board &other);
576
577
bool operator==(const Chessboard::Board& other) const {return rows*cols == other.rows*other.cols;};
578
bool operator< (const Chessboard::Board& other) const {return rows*cols < other.rows*other.cols;};
579
bool operator> (const Chessboard::Board& other) const {return rows*cols > other.rows*other.cols;};
580
bool operator>= (const cv::Size& size)const { return rows*cols >= size.width*size.height; };
581
582
/**
583
* \brief Returns a specific corner
584
*
585
* \info raises runtime_error if row col does not exists
586
*/
587
cv::Point2f& getCorner(int row,int col);
588
589
/**
590
* \brief Returns true if the cell is empty meaning at least one corner is NaN
591
*/
592
bool isCellEmpty(int row,int col);
593
594
/**
595
* \brief Returns the mapping from all corners idx to only valid corners idx
596
*/
597
std::map<int,int> getMapping()const;
598
599
/**
600
* \brief Estimates rotation of the board around the camera axis
601
*/
602
double estimateRotZ()const;
603
604
/**
605
* \brief Returns true if the cell is black
606
*
607
*/
608
bool isCellBlack(int row,int cola)const;
609
610
private:
611
// stores one cell
612
// in general a cell is initialized by the Board so that:
613
// * all corners are always pointing to a valid cv::Point2f
614
// * depending on the position left,top,right and bottom might be set to NaN
615
// * A cell is empty if at least one corner is NaN
616
struct Cell
617
{
618
cv::Point2f *top_left,*top_right,*bottom_right,*bottom_left; // corners
619
Cell *left,*top,*right,*bottom; // neighbouring cells
620
bool black; // set to true if cell is black
621
Cell();
622
bool empty()const; // indicates if the cell is empty (one of its corners has NaN)
623
int getRow()const;
624
int getCol()const;
625
};
626
627
// corners
628
enum CornerIndex
629
{
630
TOP_LEFT,
631
TOP_RIGHT,
632
BOTTOM_RIGHT,
633
BOTTOM_LEFT
634
};
635
636
Cell* getCell(int row,int column); // returns a specific cell
637
const Cell* getCell(int row,int column)const; // returns a specific cell
638
void drawEllipses(const std::vector<Ellipse> &ellipses);
639
640
// Iterator for iterating over board corners
641
class PointIter
642
{
643
public:
644
PointIter(Cell *cell,CornerIndex corner_index);
645
PointIter(const PointIter &other);
646
void operator=(const PointIter &other);
647
bool valid() const; // returns if the pointer is pointing to a cell
648
649
bool left(bool check_empty=false); // moves one corner to the left or returns false
650
bool right(bool check_empty=false); // moves one corner to the right or returns false
651
bool bottom(bool check_empty=false); // moves one corner to the bottom or returns false
652
bool top(bool check_empty=false); // moves one corner to the top or returns false
653
bool checkCorner()const; // returns ture if the current corner belongs to at least one
654
// none empty cell
655
bool isNaN()const; // returns true if the currnet corner is NaN
656
657
const cv::Point2f* operator*() const; // current corner coordinate
658
cv::Point2f* operator*(); // current corner coordinate
659
const cv::Point2f* operator->() const; // current corner coordinate
660
cv::Point2f* operator->(); // current corner coordinate
661
662
Cell *getCell(); // current cell
663
private:
664
CornerIndex corner_index;
665
Cell *cell;
666
};
667
668
std::vector<Cell*> cells; // storage for all board cells
669
std::vector<cv::Point2f*> corners; // storage for all corners
670
Cell *top_left; // pointer to the top left corner of the board in its local coordinate system
671
int rows; // number of row cells
672
int cols; // number of col cells
673
float white_angle,black_angle;
674
};
675
public:
676
677
/**
678
* \brief Creates a chessboard corner detectors
679
*
680
* \param[in] config Configuration used to detect chessboard corners
681
*
682
*/
683
Chessboard(const Parameters &config = Parameters());
684
virtual ~Chessboard();
685
void reconfigure(const Parameters &config = Parameters());
686
Parameters getPara()const;
687
688
/*
689
* \brief Detects chessboard corners in the given image.
690
*
691
* The detectors tries to find all chessboard corners of an imaged
692
* chessboard and returns them as an ordered vector of KeyPoints.
693
* Thereby, the left top corner has index 0 and the bottom right
694
* corner n*m-1.
695
*
696
* \param[in] image The image
697
* \param[out] keypoints The detected corners as a vector of ordered KeyPoints
698
* \param[in] mask Currently not supported
699
*
700
*/
701
void detect(cv::InputArray image,std::vector<cv::KeyPoint>& keypoints, cv::InputArray mask=cv::Mat())override
702
{cv::Feature2D::detect(image.getMat(),keypoints,mask.getMat());}
703
704
virtual void detectAndCompute(cv::InputArray image,cv::InputArray mask, std::vector<cv::KeyPoint>& keypoints,cv::OutputArray descriptors,
705
bool useProvidedKeyPoints = false)override;
706
707
/*
708
* \brief Detects chessboard corners in the given image.
709
*
710
* The detectors tries to find all chessboard corners of an imaged
711
* chessboard and returns them as an ordered vector of KeyPoints.
712
* Thereby, the left top corner has index 0 and the bottom right
713
* corner n*m-1.
714
*
715
* \param[in] image The image
716
* \param[out] keypoints The detected corners as a vector of ordered KeyPoints
717
* \param[out] feature_maps The feature map generated by LRJT and used to find the corners
718
* \param[in] mask Currently not supported
719
*
720
*/
721
void detectImpl(const cv::Mat& image, std::vector<cv::KeyPoint>& keypoints,std::vector<cv::Mat> &feature_maps,const cv::Mat& mask)const;
722
Chessboard::Board detectImpl(const cv::Mat& image,std::vector<cv::Mat> &feature_maps,const cv::Mat& mask)const;
723
724
// define pure virtual methods
725
virtual int descriptorSize()const override{return 0;};
726
virtual int descriptorType()const override{return 0;};
727
virtual void operator()( cv::InputArray image, cv::InputArray mask, std::vector<cv::KeyPoint>& keypoints, cv::OutputArray descriptors, bool useProvidedKeypoints=false )const
728
{
729
descriptors.clear();
730
detectImpl(image.getMat(),keypoints,mask);
731
if(!useProvidedKeypoints) // suppress compiler warning
732
return;
733
return;
734
}
735
736
protected:
737
virtual void computeImpl( const cv::Mat& image, std::vector<cv::KeyPoint>& keypoints, cv::Mat& descriptors)const
738
{
739
descriptors = cv::Mat();
740
detectImpl(image,keypoints);
741
}
742
743
// indicates why a board could not be initialized for a certain keypoint
744
enum BState
745
{
746
MISSING_POINTS = 0, // at least 5 points are needed
747
MISSING_PAIRS = 1, // at least two pairs are needed
748
WRONG_PAIR_ANGLE = 2, // angle between pairs is too small
749
WRONG_CONFIGURATION = 3, // point configuration is wrong and does not belong to a board
750
FOUND_BOARD = 4 // board was found
751
};
752
753
void findKeyPoints(const cv::Mat& image, std::vector<cv::KeyPoint>& keypoints,std::vector<cv::Mat> &feature_maps,
754
std::vector<std::vector<float> > &angles ,const cv::Mat& mask)const;
755
cv::Mat buildData(const std::vector<cv::KeyPoint>& keypoints)const;
756
std::vector<cv::KeyPoint> getInitialPoints(cv::flann::Index &flann_index,const cv::Mat &data,const cv::KeyPoint &center,float white_angle,float black_angle, float min_response = 0)const;
757
BState generateBoards(cv::flann::Index &flann_index,const cv::Mat &data, const cv::KeyPoint &center,
758
float white_angle,float black_angle,float min_response,const cv::Mat &img,
759
std::vector<Chessboard::Board> &boards)const;
760
761
private:
762
void detectImpl(const cv::Mat&,std::vector<cv::KeyPoint>&, const cv::Mat& mast =cv::Mat())const;
763
virtual void detectImpl(cv::InputArray image, std::vector<cv::KeyPoint>& keypoints, cv::InputArray mask=cv::noArray())const;
764
765
private:
766
Parameters parameters; // storing the configuration of the detector
767
};
768
}} // end namespace details and cv
769
770
#endif
771
772