"""
Execute perspective transform
"""
import numpy as np
import cv2


def perspective_transform(img):
    img_size = (500, 500)

    # Adjust src to make bird eye view
    src = np.float32(
        [[40, 130], [550, 130],
         [210, 61], [370, 61]])

    # src = np.float32(
    #     [[45, 130], [550, 130],
    #      [225, 61], [355, 61]])

    # src = np.float32(
    #     [[45, 130], [550, 130],
    #      [245, 65], [365, 65]])

    dst = np.float32(
        [[0, 500], [500, 500],
         [0, 0], [500, 0]])

    m = cv2.getPerspectiveTransform(src, dst)
    m_inv = cv2.getPerspectiveTransform(dst, src)
    warped = cv2.warpPerspective(img, m, img_size, flags=cv2.INTER_LINEAR)

    return warped, m, m_inv
