0

I need to focus in on the wheel of a car image. My thinking is that the wheel hub would be the closest thing to an actual circle or ellipse but I'm not sure how I could isolate it.

I'm using OpenCV to draw the contours but I'm not really sure where to go next.

Ultimately, I am trying to take the first image and then crop out just the wheel and add some padding. See the last image for an example.

Here's my code.

        img = cv2.imread(path)       
        gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        ret,th = cv2.threshold(gray,127,255, 0)

        contours, hierarchy = cv2.findContours(th,2,1)
        for i in contours:
            cv2.drawContours(img, i, -1, (0,255,0), 3)

enter image description here

enter image description here

Evan Lalo
  • 1,209
  • 1
  • 14
  • 34
  • You could threshold on the color of the wheel hub. Then use morphology to clean up. Then get contours. Then fit an ellipse. – fmw42 Sep 08 '21 at 18:58
  • @fmw42 I should have clarified, this needs to be dynamic enough to handle numerous cars so the color would not work. – Evan Lalo Sep 08 '21 at 19:03
  • Use edges as input and a RANSAC to find inlier and outlier. See https://stackoverflow.com/a/20734263/2393191 as an example of this can be implemented (circle detection there) – Micka Sep 08 '21 at 19:06

0 Answers0