Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

findCirclesGrid - is it really meant to be implemented this way?

Here is a small code snippet that tries to search for a circles grid on a black image. I expect it to find nothing, return false and finish.

const cv::Size patternsize(6, 5);
std::vector<cv::Point2f> centers;
cv::Mat debug(100, 100, CV_8U, cv::Scalar(0));
bool detectedCircles = cv::findCirclesGrid(debug, patternsize, centers, cv::CALIB_CB_SYMMETRIC_GRID);

Instead, it triggers a cv::Exception.

Tracing it back we find that it is thrown from a function filterOutliersByDensity:

void CirclesGridFinder::filterOutliersByDensity(const std::vector<Point2f> &samples, std::vector<Point2f> &filteredSamples)
{
  if (samples.empty())
    CV_Error( 0, "samples is empty" );

which is to be expected asfilterOutliersByDensity is called like so, with an empty freshly created vectors vector as a first parameter:

bool CirclesGridFinder::findHoles()
{
  switch (parameters.gridType)
  {
    case CirclesGridFinderParameters::SYMMETRIC_GRID:
    {
      std::vector<Point2f> vectors, filteredVectors, basis;
      Graph rng(0);
      computeRNG(rng, vectors);
      filterOutliersByDensity(vectors, filteredVectors);

I'm running opencv 4.1.0 All related opencv functions were last changed >5 years ago. This problem arouse when I've tried to run some code that worked 2 weeks ago and that I have not touched since.

Actual questions:

  1. how did it work and not trigger exceptions before?

  2. why does it not work now?

  3. how should i detect circles in an image then?

P.S.: it's my first post here and I'm very, very confused, but I hope my question is still clear. I'm happy to provide more/less detail.

findCirclesGrid - is it really meant to be implemented this way?

Here is a small code snippet that tries to search for a circles grid on a black image. I expect it to find nothing, return false and finish.

const cv::Size patternsize(6, 5);
std::vector<cv::Point2f> centers;
cv::Mat debug(100, 100, CV_8U, cv::Scalar(0));
bool detectedCircles = cv::findCirclesGrid(debug, patternsize, centers, cv::CALIB_CB_SYMMETRIC_GRID);

Instead, it triggers a cv::Exception.

Tracing it back we find that it is thrown from a function filterOutliersByDensity:

void CirclesGridFinder::filterOutliersByDensity(const std::vector<Point2f> &samples, std::vector<Point2f> &filteredSamples)
{
  if (samples.empty())
    CV_Error( 0, "samples is empty" );

which is to be expected asfilterOutliersByDensity is called like so, with an empty freshly created vectors vector as a first parameter:

bool CirclesGridFinder::findHoles()
{
  switch (parameters.gridType)
  {
    case CirclesGridFinderParameters::SYMMETRIC_GRID:
    {
      std::vector<Point2f> vectors, filteredVectors, basis;
      Graph rng(0);
      computeRNG(rng, vectors);
      filterOutliersByDensity(vectors, filteredVectors);

I'm running opencv 4.1.0 All related opencv functions were last changed >5 years ago. This problem arouse when I've tried to run some code that worked 2 weeks ago and that I have not touched since.

Actual questions:

  1. how did it work and not trigger exceptions before?

  2. why does it not work now?

  3. how should i detect circles in an image then?

P.S.: it's my first post here and I'm very, very confused, but I hope my question is still clear. I'm happy to provide more/less detail.