我已经尝试检测地板上地毯的网格图案已有一段时间了。我的代码如下:-
import cv2 as cv
from skimage.morphology import skeletonize
import numpy as np
def hough(frame):
gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
blur = cv.GaussianBlur(gray,(5,5),0)
ret,thresh1 = cv.threshold(gray,140,255,cv.THRESH_BINARY)
# cv.imshow('Thresholding',thresh1)
ske = (skeletonize(thresh1/255) * 255).astype(np.uint8)
# cv.imshow('skeletonize',ske)
lines = cv.HoughLinesP(ske, 1, np.pi/180, 400, maxLineGap=20)
for line in lines:
x1, y1, x2, y2 = line[0]
cv.line(img, (x1, y1), (x2, y2), (0, 255, 0), 3)
return
if __name__ == '__main__':
img = cv.imread('floor2.jpg')
img = cv.resize(img, (960, 540), interpolation=cv.INTER_CUBIC)
hough(img)
cv.imshow('Pattern',img)
cv.waitKey(0)
cv.destroyAllWindows()
如何在下图上提高该算法的性能?