Home>

I am trying to extract pistil pixels from a strawberry color image using image processing and display a circle circumscribing the extracted stamens.
herecv :: I'm trying to display a circumscribed circle using minEnclosingCircle, but it doesn't work.


According to opencv2.0 reference above Since is a set of 2D points, the Mat type pistil extraction image must be set to a 2D point set. I'm not sure about this conversion.
Please let me know if there is any solution.

Applicable source code

This is the source code and input image.

# include<opencv2/core/core.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<opencv2/highgui/highgui.hpp>
int
main (int argc, char * argv [])
{
  // Load image
  cv :: Mat img_input = cv :: imread ("input.jpg");
  // Calculate circumscribed circle after converting to CV_ * C2 type Mat
  cv :: Point2f center;
  float radius;
  cv :: minEnclosingCircle (cv :: Mat (img_input) .reshape (2), center, radius);
  // draw circumscribed circle
  cv :: circle (img_input, center, radius, cv :: Scalar (100,100,200), 2, CV_AA);
  cv :: namedWindow ("image", CV_WINDOW_AUTOSIZE | CV_WINDOW_FREERATIO);
  cv :: imshow ("image", img_input);
  cv :: waitKey (0);
}


Supplemental information (FW/tool version etc.)

Windows 10
Opencv 3.4.0
Visual Studio Community 2015