I want to build a line follower with OpenCV 3.1 and Python 3.4. Now I need the skeletonization but the code its bad for me and I dont know why. Maybe i have a wrong data type!?
The stream are smoothed, convert to a gray image and I used the threshold filter before this code.
size = np.size(threshold)
skel = np.zeros(threshold.shape, np.uint8)
ret, threshold = cv2.threshold(threshold, 127, 255, 0)
element = cv2.getStructuringElement(cv2.MORPH_CROSS,(3,3))
done = False
while (not done):
eroded = cv2.erode(threshold, element)
temp = cv2.dilate(eroded, element)
temp = cv2.subtract(threshold, temp)
skel = cv2.bitwise_or(skel, temp)
threshold = eroded.copy()
zeros = size - cv2.countNonZero(threshold)
if zeros==size:
done = True
After this code the stream are very very slowly. Anybody knows why?
Thanks in advance for your help.