mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Expose CirclesGridFinderParameters in findCirclesGrid.
This commit is contained in:
parent
f46fa6e096
commit
11b24eb49f
@ -714,6 +714,30 @@ found, or as colored corners connected with lines if the board was found.
|
|||||||
CV_EXPORTS_W void drawChessboardCorners( InputOutputArray image, Size patternSize,
|
CV_EXPORTS_W void drawChessboardCorners( InputOutputArray image, Size patternSize,
|
||||||
InputArray corners, bool patternWasFound );
|
InputArray corners, bool patternWasFound );
|
||||||
|
|
||||||
|
struct CV_EXPORTS_W_SIMPLE CirclesGridFinderParameters
|
||||||
|
{
|
||||||
|
CV_WRAP CirclesGridFinderParameters();
|
||||||
|
CV_PROP_RW cv::Size2f densityNeighborhoodSize;
|
||||||
|
CV_PROP_RW float minDensity;
|
||||||
|
CV_PROP_RW int kmeansAttempts;
|
||||||
|
CV_PROP_RW int minDistanceToAddKeypoint;
|
||||||
|
CV_PROP_RW int keypointScale;
|
||||||
|
CV_PROP_RW float minGraphConfidence;
|
||||||
|
CV_PROP_RW float vertexGain;
|
||||||
|
CV_PROP_RW float vertexPenalty;
|
||||||
|
CV_PROP_RW float existingVertexGain;
|
||||||
|
CV_PROP_RW float edgeGain;
|
||||||
|
CV_PROP_RW float edgePenalty;
|
||||||
|
CV_PROP_RW float convexHullFactor;
|
||||||
|
CV_PROP_RW float minRNGEdgeSwitchDist;
|
||||||
|
|
||||||
|
enum GridType
|
||||||
|
{
|
||||||
|
SYMMETRIC_GRID, ASYMMETRIC_GRID
|
||||||
|
};
|
||||||
|
GridType gridType;
|
||||||
|
};
|
||||||
|
|
||||||
/** @brief Finds centers in the grid of circles.
|
/** @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.
|
@param image grid view of input circles; it must be an 8-bit grayscale or color image.
|
||||||
@ -726,6 +750,7 @@ CV_EXPORTS_W void drawChessboardCorners( InputOutputArray image, Size patternSiz
|
|||||||
- **CALIB_CB_CLUSTERING** uses a special algorithm for grid detection. It is more robust to
|
- **CALIB_CB_CLUSTERING** uses a special algorithm for grid detection. It is more robust to
|
||||||
perspective distortions but much more sensitive to background clutter.
|
perspective distortions but much more sensitive to background clutter.
|
||||||
@param blobDetector feature detector that finds blobs like dark circles on light background.
|
@param blobDetector feature detector that finds blobs like dark circles on light background.
|
||||||
|
@param parameters struct for finding circles in a grid pattern.
|
||||||
|
|
||||||
The function attempts to determine whether the input image contains a grid of circles. If it is, the
|
The function attempts to determine whether the input image contains a grid of circles. If it is, the
|
||||||
function locates centers of the circles. The function returns a non-zero value if all of the centers
|
function locates centers of the circles. The function returns a non-zero value if all of the centers
|
||||||
@ -745,6 +770,12 @@ Sample usage of detecting and drawing the centers of circles: :
|
|||||||
@note The function requires white space (like a square-thick border, the wider the better) around
|
@note The function requires white space (like a square-thick border, the wider the better) around
|
||||||
the board to make the detection more robust in various environments.
|
the board to make the detection more robust in various environments.
|
||||||
*/
|
*/
|
||||||
|
CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize,
|
||||||
|
OutputArray centers, int flags,
|
||||||
|
const Ptr<FeatureDetector> &blobDetector,
|
||||||
|
CirclesGridFinderParameters parameters);
|
||||||
|
|
||||||
|
/** @overload */
|
||||||
CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize,
|
CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize,
|
||||||
OutputArray centers, int flags = CALIB_CB_SYMMETRIC_GRID,
|
OutputArray centers, int flags = CALIB_CB_SYMMETRIC_GRID,
|
||||||
const Ptr<FeatureDetector> &blobDetector = SimpleBlobDetector::create());
|
const Ptr<FeatureDetector> &blobDetector = SimpleBlobDetector::create());
|
||||||
|
@ -2093,7 +2093,8 @@ void cv::drawChessboardCorners( InputOutputArray _image, Size patternSize,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool cv::findCirclesGrid( InputArray _image, Size patternSize,
|
bool cv::findCirclesGrid( InputArray _image, Size patternSize,
|
||||||
OutputArray _centers, int flags, const Ptr<FeatureDetector> &blobDetector )
|
OutputArray _centers, int flags, const Ptr<FeatureDetector> &blobDetector,
|
||||||
|
CirclesGridFinderParameters parameters)
|
||||||
{
|
{
|
||||||
CV_INSTRUMENT_REGION()
|
CV_INSTRUMENT_REGION()
|
||||||
|
|
||||||
@ -2120,13 +2121,6 @@ bool cv::findCirclesGrid( InputArray _image, Size patternSize,
|
|||||||
return !centers.empty();
|
return !centers.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
CirclesGridFinderParameters parameters;
|
|
||||||
parameters.vertexPenalty = -0.6f;
|
|
||||||
parameters.vertexGain = 1;
|
|
||||||
parameters.existingVertexGain = 10000;
|
|
||||||
parameters.edgeGain = 1;
|
|
||||||
parameters.edgePenalty = -0.6f;
|
|
||||||
|
|
||||||
if(flags & CALIB_CB_ASYMMETRIC_GRID)
|
if(flags & CALIB_CB_ASYMMETRIC_GRID)
|
||||||
parameters.gridType = CirclesGridFinderParameters::ASYMMETRIC_GRID;
|
parameters.gridType = CirclesGridFinderParameters::ASYMMETRIC_GRID;
|
||||||
if(flags & CALIB_CB_SYMMETRIC_GRID)
|
if(flags & CALIB_CB_SYMMETRIC_GRID)
|
||||||
@ -2192,4 +2186,10 @@ bool cv::findCirclesGrid( InputArray _image, Size patternSize,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cv::findCirclesGrid( InputArray _image, Size patternSize,
|
||||||
|
OutputArray _centers, int flags, const Ptr<FeatureDetector> &blobDetector)
|
||||||
|
{
|
||||||
|
return cv::findCirclesGrid(_image, patternSize, _centers, flags, blobDetector, CirclesGridFinderParameters());
|
||||||
|
}
|
||||||
|
|
||||||
/* End of file. */
|
/* End of file. */
|
||||||
|
@ -551,11 +551,11 @@ CirclesGridFinderParameters::CirclesGridFinderParameters()
|
|||||||
keypointScale = 1;
|
keypointScale = 1;
|
||||||
|
|
||||||
minGraphConfidence = 9;
|
minGraphConfidence = 9;
|
||||||
vertexGain = 2;
|
vertexGain = 1;
|
||||||
vertexPenalty = -5;
|
vertexPenalty = -0.6f;
|
||||||
edgeGain = 1;
|
edgeGain = 1;
|
||||||
edgePenalty = -5;
|
edgePenalty = -0.6f;
|
||||||
existingVertexGain = 0;
|
existingVertexGain = 10000;
|
||||||
|
|
||||||
minRNGEdgeSwitchDist = 5.f;
|
minRNGEdgeSwitchDist = 5.f;
|
||||||
gridType = SYMMETRIC_GRID;
|
gridType = SYMMETRIC_GRID;
|
||||||
|
@ -119,35 +119,11 @@ struct Path
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CirclesGridFinderParameters
|
|
||||||
{
|
|
||||||
CirclesGridFinderParameters();
|
|
||||||
cv::Size2f densityNeighborhoodSize;
|
|
||||||
float minDensity;
|
|
||||||
int kmeansAttempts;
|
|
||||||
int minDistanceToAddKeypoint;
|
|
||||||
int keypointScale;
|
|
||||||
float minGraphConfidence;
|
|
||||||
float vertexGain;
|
|
||||||
float vertexPenalty;
|
|
||||||
float existingVertexGain;
|
|
||||||
float edgeGain;
|
|
||||||
float edgePenalty;
|
|
||||||
float convexHullFactor;
|
|
||||||
float minRNGEdgeSwitchDist;
|
|
||||||
|
|
||||||
enum GridType
|
|
||||||
{
|
|
||||||
SYMMETRIC_GRID, ASYMMETRIC_GRID
|
|
||||||
};
|
|
||||||
GridType gridType;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CirclesGridFinder
|
class CirclesGridFinder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CirclesGridFinder(cv::Size patternSize, const std::vector<cv::Point2f> &testKeypoints,
|
CirclesGridFinder(cv::Size patternSize, const std::vector<cv::Point2f> &testKeypoints,
|
||||||
const CirclesGridFinderParameters ¶meters = CirclesGridFinderParameters());
|
const cv::CirclesGridFinderParameters ¶meters = cv::CirclesGridFinderParameters());
|
||||||
bool findHoles();
|
bool findHoles();
|
||||||
static cv::Mat rectifyGrid(cv::Size detectedGridSize, const std::vector<cv::Point2f>& centers, const std::vector<
|
static cv::Mat rectifyGrid(cv::Size detectedGridSize, const std::vector<cv::Point2f>& centers, const std::vector<
|
||||||
cv::Point2f> &keypoint, std::vector<cv::Point2f> &warpedKeypoints);
|
cv::Point2f> &keypoint, std::vector<cv::Point2f> &warpedKeypoints);
|
||||||
@ -211,7 +187,7 @@ private:
|
|||||||
std::vector<std::vector<size_t> > *smallHoles;
|
std::vector<std::vector<size_t> > *smallHoles;
|
||||||
|
|
||||||
const cv::Size_<size_t> patternSize;
|
const cv::Size_<size_t> patternSize;
|
||||||
CirclesGridFinderParameters parameters;
|
cv::CirclesGridFinderParameters parameters;
|
||||||
|
|
||||||
CirclesGridFinder& operator=(const CirclesGridFinder&);
|
CirclesGridFinder& operator=(const CirclesGridFinder&);
|
||||||
CirclesGridFinder(const CirclesGridFinder&);
|
CirclesGridFinder(const CirclesGridFinder&);
|
||||||
|
@ -14,7 +14,8 @@ class_ignore_list = (
|
|||||||
#core
|
#core
|
||||||
"FileNode", "FileStorage", "KDTree", "KeyPoint", "DMatch",
|
"FileNode", "FileStorage", "KDTree", "KeyPoint", "DMatch",
|
||||||
#features2d
|
#features2d
|
||||||
"SimpleBlobDetector"
|
"SimpleBlobDetector",
|
||||||
|
"CirclesGridFinderParameters"
|
||||||
)
|
)
|
||||||
|
|
||||||
const_ignore_list = (
|
const_ignore_list = (
|
||||||
|
@ -798,6 +798,21 @@ PyObject* pyopencv_from(const Size& sz)
|
|||||||
return Py_BuildValue("(ii)", sz.width, sz.height);
|
return Py_BuildValue("(ii)", sz.width, sz.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
bool pyopencv_to(PyObject* obj, Size_<float>& sz, const char* name)
|
||||||
|
{
|
||||||
|
(void)name;
|
||||||
|
if(!obj || obj == Py_None)
|
||||||
|
return true;
|
||||||
|
return PyArg_ParseTuple(obj, "ff", &sz.width, &sz.height) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
PyObject* pyopencv_from(const Size_<float>& sz)
|
||||||
|
{
|
||||||
|
return Py_BuildValue("(ff)", sz.width, sz.height);
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
bool pyopencv_to(PyObject* obj, Rect& r, const char* name)
|
bool pyopencv_to(PyObject* obj, Rect& r, const char* name)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user