0

I want to detect circle in a picture by using haar cascade. I created an cascade xml.

import cv2
import numpy as np
img = cv2.imread("C://OpenCVcascade//resimler//coins.jpg")
circles_cascade = cv2.CascadeClassifier("C://Cascade//dairetanima.xml")

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
circles = circles_cascade.detectMultiScale(gray, 1.1, 1)

if circles is not None:
    circles = np.uint16(np.around(circles))
    for (x, y, w, h) in circles:
        center = (x + w // 2, y + h // 2)
        radius = (w + h) // 4
        cv2.circle(img, center, radius, (255, 0, 0), 2)

cv2.imshow('image', img)

cv2.waitKey()
cv2.destroyAllWindows()

My result: enter image description here

I already know, there are different method to detect circle. But I am trying to do with cascade method. Because after this part, I will use it for real time detection.

2
  • Try this link pyimagesearch.com/2014/07/21/… Commented May 24, 2020 at 2:49
  • I already looked this link. I was trying to do it with cascade method. But I guess, we use cascade method to find specific objects likes car,hand,human. Circle is just a shape. So cascade method is not suitable to detect circle or another shape. Thanks. Commented May 24, 2020 at 22:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.