Home > other >  Detection of arc
Detection of arc

Time:03-02

I am a beginner, OpenCV is doing find arc project requirements from the picture, I saw you recommend using round looking for circular arc in the picture, in accordance with the sample picture. Write the code. But found that can find only part of the circular arc, other part can't identify, which master can help have a look, I used the wrong or hoff circle is not suitable for this kind of situation? Appreciate

Code:
# coding: utf-8

The import cv2
The import numpy as np

# read source map
Img=cv2. Imread (r "D: \ \ 1. JPG")
Cv2. Imshow (' image 'img)

# pretreatment
Gray=cv2. CvtColor (img, cv2 COLOR_RGB2GRAY)
The blur=cv2. GaussianBlur (gray, (17, 17), 0)
The kernel=cv2. GetStructuringElement (cv2 MORPH_RECT, (10, 10))
Open_=cv2. MorphologyEx (the blur, cv2 MORPH_OPEN, kernel)
Edge=cv2. Canny (open_, 50, 100, apertureSize=3)

# hoff round
Circles=cv2. HoughCircles (edge, cv2. HOUGH_GRADIENT, 1, 30, param1=100, param2=30, minRadius=0, maxRadius=0)
Circles=np. Uint16 (np) around (circles) # circles contain's center and radius value into an integer
For I circles in [0, :] :
Cv2. Circle (img, (I [0], I [1]), I [2], (0, 0, 255), 2) # circle
Cv2. Circle (img, (I [0], I [1]), 2, (0, 0, 255), 2) # painting circle
Cv2. Imshow (" circles ", img)

# exit
Cv2. WaitKey (0)
Cv2. DestroyAllWindows ()

Source:


Results: only identify three, has failed to identify several other,

  • Related