How can I detect pipeline cracks using OpenCV and Python? I have developed a robot that captures images of the pipeline interior as it moves. The requirement was to be able to detect cracks inside. So far i tried several OpenCV codes that find the crack contours but i was not successful.

Code I'm working on:

import cv2
import numpy as np
image = cv2.imread('pipe_photo1.jpg')
blurred = cv2.pyrMeanShiftFiltering(image,41,91)
gray = cv2.cvtColor(blurred,cv2.COLOR_BGR2GRAY)
ret, threshold = cv2.threshold(gray,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
_, contours, _ = cv2.findContours(threshold, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)
print (len(contours))

cv2.drawContours(image,contours, -1,(0,0,255),6)
cv2.namedWindow("Display",cv2.WINDOW_NORMAL)
cv2.imshow("Display",image)
cv2.waitKey()


Below is the image i obtained from the camera. I want to detect only the crack shown at the bottom of the pipe and be able to draw it using red lines. Your help will really save me in achieving my objectives before its due.
Try this:


Don't convert the image to grayscale, instead convert to HSV
Then, by changing the range of H,S and V, try to mask the crack (using a trackbar can be very helpful) 


For example:

lower_value_blue = np.array([80,106,5])    # creating a range of HSV colours
higher_value_blue = np.array([150,255,150])
mask1 = cv2.inRange(blur1,lower_value_blue,higher_value_blue)


This one mask blue colour, without using trackbar

Hope you will get the result