使用霍夫变换进行安全带检测

时间:2019-09-12 06:44:36

标签: image-processing

我想检测安全带是否系好。我已经使用了以下步骤。

  1. 颜色分割

  2. 图像模糊

  3. 边缘检测

  4. 形态转换

  5. 具有概率性

  6. 角度过滤

现在,我无法从形态转换返回的图像中提取特征。我将附加通过形态转换返回的输出。任何帮助将不胜感激。

img = cv2.imread('belt1.png')
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

#linek = np.zeros((11,11),dtype=np.uint8)
#linek[5,...]=1
#x=cv2.morphologyEx(gray, cv2.MORPH_OPEN, linek ,iterations=1)
#gray-=x

#kernel = np.ones((5, 5), np.uint8)
#gray = cv2.dilate(gray, kernel, iterations=1)
#gray = cv2.erode(gray, kernel, iterations=1)

kernel_size = 5
blur_gray = cv2.GaussianBlur(gray,(kernel_size, kernel_size),0)

low_threshold = 50
high_threshold = 150
kernel = np.ones((5,5),np.uint8)
edges = cv2.Canny(blur_gray, low_threshold, high_threshold)

edges = cv2.morphologyEx(edges, cv2.MORPH_CLOSE, kernel)

rho = 1  # distance resolution in pixels of the Hough grid
theta = np.pi / 180  # angular resolution in radians of the Hough grid
threshold = 80  # minimum number of votes (intersections in Hough grid cell)
min_line_length = 100  # minimum number of pixels making up a line
max_line_gap = 40  # maximum gap in pixels between connectable line segments
line_image = np.copy(img) * 0  # creating a blank to draw lines on

# Run Hough on edge detected image
# Output "lines" is an array containing endpoints of detected line segments
lines = cv2.HoughLinesP(edges, rho, theta, threshold, np.array([]),
                    min_line_length, max_line_gap)

在这里我无法提取功能:

enter image description here

0 个答案:

没有答案
相关问题