def _intersect(rect1, rect2):
    """
    Check whether two rectangles intersect.
    :param rect1, rect2: a rectangle represented with a turple(x,y,w,h,approxPoly_corner_count)
    :return whether the two rectangles intersect
    """
    # check x
    x_intersect = False
    if rect1[0] <= rect2[0] and rect2[0] - rect1[0] < rect1[2]:
        x_intersect = True
    if rect2[0] <= rect1[0] and rect1[0] - rect2[0] < rect2[2]:
        x_intersect = True
    # check y
    y_intersect = False
    if rect1[1] <= rect2[1] and rect2[1] - rect1[1] < rect1[3]:
        y_intersect = True
    if rect2[1] <= rect1[1] and rect1[1] - rect2[1] < rect2[3]:
        y_intersect = True
    return x_intersect and y_intersect