Skip to content

Commit

Permalink
Added safeguards to check if OpenCV core is available
Browse files Browse the repository at this point in the history
  • Loading branch information
rlagneau committed Aug 29, 2023
1 parent e8325b4 commit 97abac3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,12 @@ class VISP_EXPORT vpCircleHoughTransform
*/
vpCircle2D(const vpImagePoint &center, const float &radius) : m_center(center), m_radius(radius) { }

#ifdef HAVE_OPENCV_CORE
/*!
* Constructor from an OpenCV vector that contains [center_x, center_y, radius].
*/
vpCircle2D(const cv::Vec3f &vec) : m_center(vec[1], vec[0]), m_radius(vec[2]) { }
#endif

/*!
* Default destructor.
Expand Down Expand Up @@ -417,13 +419,15 @@ class VISP_EXPORT vpCircleHoughTransform

// // Detection methods

#ifdef HAVE_OPENCV_CORE
/**
* \brief Perform Circle Hough Transform to detect the circles in an OpenCV image.
*
* \param[in] I The input gray scale image.
* \return std::vector<vpCircle2D> The list of 2D circles detected in the image.
*/
std::vector<vpCircle2D> detect(const cv::Mat &cv_I);
#endif

/**
* \brief Convert the input image in a gray-scale image and then
Expand Down
2 changes: 2 additions & 0 deletions modules/imgproc/src/vpCircleHoughTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,15 @@ vpCircleHoughTransform::detect(const vpImage<vpRGBa> &I)
return detect(I_gray);
}

#ifdef HAVE_OPENCV_CORE
std::vector<vpCircleHoughTransform::vpCircle2D>
vpCircleHoughTransform::detect(const cv::Mat &cv_I)
{
vpImage<unsigned char> I_gray;
vpImageConvert::convert(cv_I, I_gray);
return detect(I_gray);
}
#endif

std::vector<vpCircleHoughTransform::vpCircle2D>
vpCircleHoughTransform::detect(const vpImage<unsigned char> &I, const int &nbCircles)
Expand Down

0 comments on commit 97abac3

Please sign in to comment.