def check_position_detection(bounds):
    """Check whether the specified range of 5 intervals has the right
    proportions to correspond to a slice through a position detection pattern.

    An ideal slice through a position detection pattern consists of
    5 intervals colored B,W,B,W,B with lengths proportional to 1,1,3,1,1.

    Returns:
        (center_coord, pixels_per_module) if this could be a position
        detection pattern, otherwise (0, 0).
    """

    # Expected relative positions of black/white boundaries
    # within the position detection pattern.
    expect_bound_pos = [-3.5, -2.5, -1.5, 1.5, 2.5, 3.5]

    if (len(bounds) != 6) or (bounds[4] >= bounds[5]):
        return (0, 0)

    pattern_width = float(bounds[5] - bounds[0])
    middle_width = float(bounds[3] - bounds[2])
    if (pattern_width < 7) or (middle_width < 3):
        return (0, 0)

    center = float(sum(bounds)) / 6.0
    pitch = (pattern_width + middle_width) / 10.0

    good = True
    for k in range(6):
        rel_bound_pos = (bounds[k] - center) / pitch
        if abs(rel_bound_pos - expect_bound_pos[k]) >= 0.5:
            good = False
            break

    if not good:
        return (0, 0)

    return (center, pitch)