mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 22:44:02 +08:00
Merge pull request #9596 from paroj:circle_board_params
This commit is contained in:
commit
ab748188b1
@ -783,6 +783,14 @@ struct CV_EXPORTS_W_SIMPLE CirclesGridFinderParameters
|
||||
GridType gridType;
|
||||
};
|
||||
|
||||
struct CV_EXPORTS_W_SIMPLE CirclesGridFinderParameters2 : public CirclesGridFinderParameters
|
||||
{
|
||||
CV_WRAP CirclesGridFinderParameters2();
|
||||
|
||||
CV_PROP_RW float squareSize; //!< Distance between two adjacent points. Used by CALIB_CB_CLUSTERING.
|
||||
CV_PROP_RW float maxRectifiedDistance; //!< Max deviation from predicion. Used by CALIB_CB_CLUSTERING.
|
||||
};
|
||||
|
||||
/** @brief Finds centers in the grid of circles.
|
||||
|
||||
@param image grid view of input circles; it must be an 8-bit grayscale or color image.
|
||||
@ -820,6 +828,12 @@ CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize,
|
||||
const Ptr<FeatureDetector> &blobDetector,
|
||||
CirclesGridFinderParameters parameters);
|
||||
|
||||
/** @overload */
|
||||
CV_EXPORTS_W bool findCirclesGrid2( InputArray image, Size patternSize,
|
||||
OutputArray centers, int flags,
|
||||
const Ptr<FeatureDetector> &blobDetector,
|
||||
CirclesGridFinderParameters2 parameters);
|
||||
|
||||
/** @overload */
|
||||
CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize,
|
||||
OutputArray centers, int flags = CALIB_CB_SYMMETRIC_GRID,
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"class_ignore_list": [
|
||||
"CirclesGridFinderParameters"
|
||||
"CirclesGridFinderParameters",
|
||||
"CirclesGridFinderParameters2"
|
||||
],
|
||||
"missing_consts" : {
|
||||
"Calib3d": {
|
||||
|
@ -2094,9 +2094,19 @@ void cv::drawChessboardCorners( InputOutputArray _image, Size patternSize,
|
||||
nelems, patternWasFound );
|
||||
}
|
||||
|
||||
bool cv::findCirclesGrid( InputArray _image, Size patternSize,
|
||||
bool cv::findCirclesGrid( InputArray image, Size patternSize,
|
||||
OutputArray centers, int flags,
|
||||
const Ptr<FeatureDetector> &blobDetector,
|
||||
CirclesGridFinderParameters parameters)
|
||||
{
|
||||
CirclesGridFinderParameters2 parameters2;
|
||||
*((CirclesGridFinderParameters*)¶meters2) = parameters;
|
||||
return cv::findCirclesGrid2(image, patternSize, centers, flags, blobDetector, parameters2);
|
||||
}
|
||||
|
||||
bool cv::findCirclesGrid2( InputArray _image, Size patternSize,
|
||||
OutputArray _centers, int flags, const Ptr<FeatureDetector> &blobDetector,
|
||||
CirclesGridFinderParameters parameters)
|
||||
CirclesGridFinderParameters2 parameters)
|
||||
{
|
||||
CV_INSTRUMENT_REGION()
|
||||
|
||||
@ -2115,19 +2125,19 @@ bool cv::findCirclesGrid( InputArray _image, Size patternSize,
|
||||
points.push_back (keypoints[i].pt);
|
||||
}
|
||||
|
||||
if(flags & CALIB_CB_CLUSTERING)
|
||||
{
|
||||
CirclesGridClusterFinder circlesGridClusterFinder(isAsymmetricGrid);
|
||||
circlesGridClusterFinder.findGrid(points, patternSize, centers);
|
||||
Mat(centers).copyTo(_centers);
|
||||
return !centers.empty();
|
||||
}
|
||||
|
||||
if(flags & CALIB_CB_ASYMMETRIC_GRID)
|
||||
parameters.gridType = CirclesGridFinderParameters::ASYMMETRIC_GRID;
|
||||
if(flags & CALIB_CB_SYMMETRIC_GRID)
|
||||
parameters.gridType = CirclesGridFinderParameters::SYMMETRIC_GRID;
|
||||
|
||||
if(flags & CALIB_CB_CLUSTERING)
|
||||
{
|
||||
CirclesGridClusterFinder circlesGridClusterFinder(parameters);
|
||||
circlesGridClusterFinder.findGrid(points, patternSize, centers);
|
||||
Mat(centers).copyTo(_centers);
|
||||
return !centers.empty();
|
||||
}
|
||||
|
||||
const int attempts = 2;
|
||||
const size_t minHomographyPoints = 4;
|
||||
Mat H;
|
||||
@ -2191,7 +2201,7 @@ bool cv::findCirclesGrid( InputArray _image, Size patternSize,
|
||||
bool cv::findCirclesGrid( InputArray _image, Size patternSize,
|
||||
OutputArray _centers, int flags, const Ptr<FeatureDetector> &blobDetector)
|
||||
{
|
||||
return cv::findCirclesGrid(_image, patternSize, _centers, flags, blobDetector, CirclesGridFinderParameters());
|
||||
return cv::findCirclesGrid2(_image, patternSize, _centers, flags, blobDetector, CirclesGridFinderParameters2());
|
||||
}
|
||||
|
||||
/* End of file. */
|
||||
|
@ -559,6 +559,13 @@ CirclesGridFinderParameters::CirclesGridFinderParameters()
|
||||
gridType = SYMMETRIC_GRID;
|
||||
}
|
||||
|
||||
CirclesGridFinderParameters2::CirclesGridFinderParameters2()
|
||||
: CirclesGridFinderParameters()
|
||||
{
|
||||
squareSize = 1.0f;
|
||||
maxRectifiedDistance = squareSize/2.0f;
|
||||
}
|
||||
|
||||
CirclesGridFinder::CirclesGridFinder(Size _patternSize, const std::vector<Point2f> &testKeypoints,
|
||||
const CirclesGridFinderParameters &_parameters) :
|
||||
patternSize(static_cast<size_t> (_patternSize.width), static_cast<size_t> (_patternSize.height))
|
||||
|
@ -56,11 +56,11 @@ class CirclesGridClusterFinder
|
||||
CirclesGridClusterFinder& operator=(const CirclesGridClusterFinder&);
|
||||
CirclesGridClusterFinder(const CirclesGridClusterFinder&);
|
||||
public:
|
||||
CirclesGridClusterFinder(bool _isAsymmetricGrid)
|
||||
CirclesGridClusterFinder(const cv::CirclesGridFinderParameters2 ¶meters)
|
||||
{
|
||||
isAsymmetricGrid = _isAsymmetricGrid;
|
||||
squareSize = 1.0f;
|
||||
maxRectifiedDistance = (float)(squareSize / 2.0);
|
||||
isAsymmetricGrid = parameters.gridType == cv::CirclesGridFinderParameters::ASYMMETRIC_GRID;
|
||||
squareSize = parameters.squareSize;
|
||||
maxRectifiedDistance = parameters.maxRectifiedDistance;
|
||||
}
|
||||
void findGrid(const std::vector<cv::Point2f> &points, cv::Size patternSize, std::vector<cv::Point2f>& centers);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user