我试图在模拟显示器的视频中检测时钟指针并提取它指向的值。我正在使用Python和OpenCV。
我基本上做的是:
守则:
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)
我玩了很多参数来改善结果。目前的状态如下: