I'm trying to apply the hough probabilistic transform in a tube, and I already have a well-filtered image (edges).
My need is to recognize any of these straight lines (attached figure) that are in the middle of the tube so i can detect the liquid level, but I can not do this. Do anyone know how i can solve this?
import cv2
import numpy as np
img = cv2.imread('tube.png')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.imwrite('gray.png',gray)
edges = cv2.Canny(gray,350,720,apertureSize = 3)
cv2.imwrite('edges.png',edges)
minLineLength = 30
maxLineGap = 0
lines = cv2.HoughLinesP(edges,1,np.pi/180,10,minLineLength,maxLineGap)
for x1,y1,x2,y2 in lines[0]:
cv2.line(img,(x1,y1),(x2,y2),(0,255,0),4)
cv2.imwrite('houghlines.png',img)
My actual results are in the 'houghlines' attached figure. What appears is a green and vertical line, but i need a horizontal one so i can detect the liquid level.
thanks in advance.