Python (backend) code: import cv2 import numpy as np def detect_lane_lines(image): # Convert image to grayscale gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # Apply Gaussian blur to reduce noise blurred = cv2.GaussianBlur(gray, (5, 5), 0) # Perform edge detection using Canny edges = cv2.Canny(blurred, 50, 150) # Define region of interest (ROI) height, width = image.shape[:2] mask = np.zeros_like(edges) roi_vertices = np.array([[(0, height), (width / 2, height / 2), (width, height)]], dtype=np.int32) cv2.fillPoly(mask, roi_vertices, 255) masked_edges = cv2.bitwise_and(edges, mask) # Perform Hough line detection lines = cv2.HoughLinesP(masked_edges, 2, np.pi / 180, 100, np.array([]), minLineLength=40, maxLineGap=5) # Draw detected lane lines on the original image line_image = np.zeros_like(image) if lines is not None: for line in lines: x1, y1, x2, y2 = line[0] cv2.line(line_image, (x1, y1), (x2, y2), (0, 255, 0), 5) # Combine lane lines with original image result = cv2.addWeighted(image, 0.8, line_image, 1, 0) return result # Example usage image_path = 'path_to_image.jpg' image = cv2.imread(image_path) result = detect_lane_lines(image) cv2.imshow('Lane Lines Detection', result) cv2.waitKey(0) cv2.destroyAllWindows()