Thursday, 7 July 2016

python - How to improve detection of Probalistic Hough-Lines-Transform?

I'm trying to detect a clock hand in a video of an analogue display and extract the value it points to. I'm using Python with OpenCV for this.



What I essentially do is:





  1. I'm using a Gaussian Blur to lower the noise in the current image.

  2. I use Canny Edge Detection to filter the edges

  3. I apply the probalistic Hough Line Transform



The Code for it:



def detect_clock_hand(img, center):
# Convert to gray
gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)


# Apply gaussian blur
blur = cv2.GaussianBlur(gray, (11, 11), 0, 0)

# Apply sobel edge detection
edges = cv2.Canny(blur, 30, 40)

# Apply HoughTransform
lines = cv2.HoughLinesP(edges, 10, np.pi / 180, 5, 15, 50)


#Filter lines in a given radius
filtered_edges = util.filter_edges(lines, center)


I played a lot with the parameters to improve the results. The current status looks like this:




  1. Canny
    Canny


  2. Hough

    HoughLineTransformP




As you can see, the result just marks a part of the clockhand. And that part isn't event a 'good' part from what I can tell from the Canny Edge Detection. I'm wondering if I use the Hough Transform wrong or the Edge Detection actually isn't as good as I think it is. Since I'm new to Image Processing, I'd be greatful for any advice.

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...