code:
import cv2
import numpy as np

# Define the dimensions of the court
court_width = 20.0  # in feet
court_length = 44.0  # in feet
kitchen_length = 14.0  # in feet
service_length = 7.0  # in feet
basline_length = court_length - kitchen_length

# Define the scale for mapping the court onto the minimap
scale = 20.0  # each pixel on the minimap corresponds to 1 foot on the court

# Define the colors for the court lines
line_color = (255, 255, 255)  # white
baseline_color = (0, 255, 0)  # green
kitchen_color = (0, 0, 255)  # red
service_color = (255, 0, 0)  # blue

# Create the minimap image
minimap_width = int(court_width * scale)
minimap_length = int(court_length * scale)
minimap = np.zeros((minimap_width, minimap_length, 3), dtype=np.uint8)
court_lines = np.float32([[0, kitchen_length*scale], [basline_length*scale + service_length*scale, kitchen_length*scale], [basline_length*scale + service_length*scale, court_width*scale], [service_length*scale, court_width*scale]])


# Draw the court lines on the minimap
cv2.rectangle(minimap, (0, 0), (minimap_length, minimap_width), line_color, thickness=2)
cv2.line(minimap, (0, int(kitchen_length*scale)), (minimap_length, int(kitchen_length*scale)), line_color, thickness=2)
cv2.line(minimap, (int(service_length*scale), 0), (int(service_length*scale), minimap_width), line_color, thickness=2)
cv2.line(minimap, (int(basline_length*scale+service_length*scale), 0), (int(basline_length*scale+service_length*scale), minimap_width), baseline_color, thickness=2)

# Initialize the video capture
cap = cv2.VideoCapture('1_1.mp4')

while True:
    # Read the video frame
    ret, frame = cap.read()

    # Convert the frame to grayscale
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    # Apply a blur to reduce noise
    blur = cv2.GaussianBlur(gray, (5, 5), 0)

  	# Apply edge detection to extract the lines
    edges = cv2.Canny(blur, 50, 150, apertureSize=3)
  
  	# Apply Hough Transform to detect straight lines 
    lines = cv2.HoughLinesP(edges, rho=1, theta=np.pi/180, threshold=50, minLineLength=100, maxLineGap=10)
    #lines = np.float32([line[0] for line in lines])
    #print(court_lines.shape, court_lines.dtype)

    if lines is not None:
        # Transform the detected court lines to the minimap
        lines = np.float32(lines.reshape(-1, 4))
        if lines.shape[0] >= 4:
            print(f"lines shape: {lines.shape}, court_lines shape: {court_lines.shape}")
            transform = cv2.getPerspectiveTransform(np.array(lines, np.float32), court_lines)
            transformed_court = cv2.warpPerspective(frame, transform, (minimap_length, minimap_width))

        # Overlay the minimap onto the frame
        result = cv2.addWeighted(frame, 0.8, minimap, 1.0, 0.0)

    # Display the resulting images
    cv2.imshow('Original', result)
    cv2.imshow('Transformed', transformed_court)

    if cv2.waitKey(1) == ord('q'):
        break

# Release the video capture and close all windows
cap.release()
cv2.destroyAllWindows()

error:
lines shape: (99, 4), court_lines shape: (4, 2)
Traceback (most recent call last):
  File "/Users/surabhi/Documents/kalman/court", line 59, in <module>
    transform = cv2.getPerspectiveTransform(np.array(lines, np.float32), court_lines)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cv2.error: OpenCV(4.7.0) /Users/runner/work/opencv-python/opencv-python/opencv/modules/imgproc/src/imgwarp.cpp:3522: error: (-215:Assertion failed) src.checkVector(2, CV_32F) == 4 && dst.checkVector(2, CV_32F) == 4 in function 'getPerspectiveTransform'