0

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.

Yggdrasill
  • 166
  • 1
  • 3
  • 16
  • 1
    try line segment detection – Micka Jun 26 '17 at 13:07
  • @Piglet, what approach would be better and why? Also, what basics are you talking about? I want to improve, so any advice to which direction to research would be great. – Yggdrasill Jun 26 '17 at 13:50
  • @Micka, I'm doing so right now. I'll post a reply, when I have something working that also is better. – Yggdrasill Jun 26 '17 at 13:50
  • I am talking about the basics of image processing. You said you were knew to image processing but jump right into interpreting low quality video footage. there are many ways to solve this in a more robust manner than hough transform. for example you could extract the hand blob and get its main axis. there are many other techniques you would know if you had read at least one book on image processing. it would also make sense to restrict your processing ot the display to remove anything that does not contribute to what you are looking for – Piglet Jun 26 '17 at 14:06
  • 1
    @Piglet, well isn't that how you start kinda? Im reading a lot of papers and ressources to get into it. I am also attending to a class in Uni which covers image processing, though in a more general manner. And regarding the latter: The code I sent is a breakdown to the core functionality. Meaning, I'm actually doing some more things. For example, you see the red circle? That is the only area I'm checking for features. I'll look into extracting hand blobs. Thank you for the advice! – Yggdrasill Jun 26 '17 at 14:11
  • I would probably start with color range filtering using `inRange()` since the analog gauge is a pretty distinct color. You might also try dilating the edges for a better Hough circle (there are multiple circles right next to each other, so this might turn it into one fat circle). You can use the filtered circle, or the circle from Hough, to define an ROI and then do processing strictly inside the circle to get better results that don't require getting information from the whole image. Also a stddev of `0` in `GaussianBlur` is probably not what you want. – alkasm Jun 28 '17 at 06:28
  • @AlexanderReynolds, I should consider that probably, to have a better detection. Though I don't see anything other than the hand itself making a problem here. I'm already doing the detection only inside of the circle. I'll look more into GaussianBlur and understand the effectof the standard deviation. – Yggdrasill Jul 01 '17 at 11:22

0 Answers0