Home:ALL Converter>skeletonization in videostream with opencv and python

skeletonization in videostream with opencv and python

Ask Time:2017-01-20T03:20:55         Author:Raga

Json Formatter

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.

Author:Raga,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/41749982/skeletonization-in-videostream-with-opencv-and-python
yy