Ask Your Question

Analog clock read

asked 2019-05-08 03:38:39 -0500

Ronald gravatar image


i am trying to read the time on an analogue clock. It's the same clock, black and white, clearly visible so no problems. Can someone give me some pointers how to read? I can only find code for an analogue gauge. I think I need - Detect circles - Detect hands and angles? - Detect difference between hours (short hand) and Minutes (Long hand)

edit retag flag offensive close merge delete



what did you try? this is a forum for helping with your opencv related problems, not to solve your projects. see faq

kbarni gravatar imagekbarni ( 2019-05-08 07:08:29 -0500 )edit

I found this already ( but that's by using Matlab instead of opencv.I also found code to recognize 1 hand in for example a gauge. The Matlab code seems fine so I want to use that as the basic.

Ronald gravatar imageRonald ( 2019-05-08 07:41:06 -0500 )edit

Ok, then here's the algorithm:

Good news: you have everything you need in OpenCV. But we won't solve it for you!

kbarni gravatar imagekbarni ( 2019-05-09 05:07:18 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2019-05-10 15:57:40 -0500

Here is a different approach.

The image below shows several steps available in OpenCV.

  1. Find the circle of the clock and use the warpPolar transformation.
    Rotate this image by 180 to get the 2nd image.

  2. Apply a dilation with a wide Rect kernal about 120 x 1 to get the 3rd image.

  3. Do an inverse binary threshold to get the last image.

You can then filter the contours in this last image by area and center x position to leave only the contours that would be the hour, minute and second hand.

We know that 3:00 will be on top, 9:00 in the middle and 6:00 at the bottom so it shouldn't be too difficult to map the center y values of the remaining contours to their values on the clock.

image description

edit flag offensive delete link more


You can use this blue print

  1. Isolate the clock from the rest of the image 2.Apply edge detection on the image
  2. Use Hough transform to isolate watch hands
  3. Calculate line angles
  4. Filter out irrelevant lines
  5. Compute the time
Afflospark gravatar imageAfflospark ( 2019-05-11 14:23:34 -0500 )edit

Question Tools

1 follower


Asked: 2019-05-08 03:38:39 -0500

Seen: 1,550 times

Last updated: May 10 '19