title: Detecting circles in custom shapes
body: <p>I need help to detect circles in my images ,
  When I run my code the circle is not searched instead the returned shape is an ellipse
  , sorry bad English</p>
  <p>Input image:</p>
  <p><img src="https://i.stack.imgur.com/Rax9K.jpg" alt="Input Image" /></p>
  <p>Result image:</p>
  <p><img src="https://i.stack.imgur.com/raNJz.png" alt="Result Image" /></p>
  <p>My code :</p>
  <pre><code>public Mat Run(string imgPath , int thresholdValue = 150)
  {
          var img=Cv2.ImRead(imgPath);
          Bitmap bitmap = MatToBitmap(img);
          pictureBox1.Image = bitmap;
  
          Mat gray = img.CvtColor(ColorConversionCodes.BGR2GRAY);
  
          ThresholdImg = gray.Threshold(thresholdValue, 255, ThresholdTypes.Binary);
          Bitmap threshold = MatToBitmap(ThresholdImg);
          pictureBox2.Image = threshold;
  
          //Cv2.ImShow(&quot;Threshold&quot;, ThresholdImg);
          Mat gaussImg = ThresholdImg.GaussianBlur(new OpenCvSharp.Size(5, 5), 0.8);
  
          //Cv2.ImShow(&quot;GaussianBlur&quot;, gaussImg);
          Mat medianImg = ThresholdImg.MedianBlur(5);
  
          //Cv2.ImShow(&quot;MedianBlur&quot;, medianImg);
          Mat kernel = new Mat(15, 15, MatType.CV_8UC1);
          Mat DilateImg = ThresholdImg.Dilate(kernel);
          Mat binary = DilateImg.Erode(kernel);
  
          //Cv2.ImShow(&quot;Dilate &amp; Erode&quot;, binary);
          Mat element = Cv2.GetStructuringElement(MorphShapes.Ellipse, new OpenCvSharp.Size(5, 5));
          Mat openImg = ThresholdImg.MorphologyEx(MorphTypes.Open, element);
  
          //Cv2.ImShow(&quot;Dilate &amp; Erode&quot;, openImg);
          Rect roi = new Rect(0, 0, bitmap.Width, bitmap.Height);
          Mat ROIimg = new Mat(openImg, roi);
          Cv2.ImShow(&quot;ROI Image&quot;, ROIimg);
          OpenCvSharp.Point[][] contours;
          HierarchyIndex[] hierachy;
          Cv2.FindContours(ROIimg, out contours, out hierachy, RetrievalModes.List, ContourApproximationModes.ApproxTC89KCOS);
  
          //According to the found contour points, fit the ellipse
          for (int i = 0; i &lt; contours.Length; i++)
          {
              //The fitting function must have at least 5 points, if less than it is not fitting
              if (contours[i].Length &lt; 5) continue;
              //Ellipse fitting
              var rrt = Cv2.FitEllipse(contours[i]);
          }
    }
  </code></pre>
  <p>How to accurately detect a circle? , sorry i am new , i cant post my image</p>