def process_image_v6(original_image): processed_image1 = lap(original_image) processed_image2 = find_traffic_light(original_image) processed_image = cv2.add(processed_image1, processed_image2) processed_image = cv2.normalize(processed_image, None, alpha=0, beta=1, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F) return processed_image
def process_image_2range(original_image): original_image = cv2.normalize(original_image, None, alpha=0, beta=1, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F) processed_image1 = find_lines_inrange(original_image, 0, 0, 77, 255, 87, 255) processed_image2 = find_traffic_light(original_image) processed_image3 = find_lines_inrange(original_image, 98, 90, 123, 176, 255, 255) processed_image = cv2.add(processed_image1, processed_image2) processed_image = cv2.add(processed_image, processed_image3) return processed_image
def process_image_v3(original_image): processed_image1 = transform2(original_image) processed_image2 = find_traffic_light(original_image) processed_image = cv2.add(processed_image1, processed_image2) return processed_image
def process_image_v2(original_image): processed_image1 = proc_screen(original_image) processed_image2 = find_traffic_light(original_image) processed_image = cv2.add(processed_image1, processed_image2) return processed_image
def process_image_v1(original_image): Y = original_image * 1 minimap = Y[130:180, 224:295, :] vertices_roi_minimap_warped = np.array([[300, 190], [228, 190], [300, 140], [300, 190]]) pts1_mm = np.float32([[0, 0], [71, 0], [0, 50], [71, 50]]) # minimap pts2_mm = np.float32([[229, 150], [300, 150], [229, 200], [300, 200]]) pts1 = np.float32([[140, 120], [160, 120], [90, 200], [210, 200]]) # road pts2 = np.float32([[100, 0], [200, 0], [100, 200], [200, 200]]) M = cv2.getPerspectiveTransform(pts1, pts2) M_m = cv2.getPerspectiveTransform(pts1_mm, pts2_mm) warped_mm = cv2.warpPerspective(minimap, M_m, (300, 200)) warped = cv2.warpPerspective(original_image, M, (300, 200)) mask = np.full_like(warped, 255) cv2.fillPoly(mask, [vertices_roi_minimap_warped], (0, 0, 0)) masked = cv2.bitwise_and(warped, mask) # CANNY canny_warped = cv2.GaussianBlur(masked, (3, 3), 0) canny_warped = cv2.cvtColor(canny_warped, cv2.COLOR_RGB2GRAY) canny_warped = cv2.Canny(canny_warped, threshold1=80, threshold2=100, apertureSize=3) # #FINDING LINES minLineLength = 20 maxLineGap = 20 left_coordinate = [] right_coordinate = [] try: lines = cv2.HoughLinesP(image=canny_warped, rho=cv2.HOUGH_PROBABILISTIC, theta=np.pi / 180, threshold=25, minLineLength=minLineLength, maxLineGap=maxLineGap) canny_warped = cv2.cvtColor(canny_warped, cv2.COLOR_GRAY2RGB) if lines is not None: for line in lines: x1, y1, x2, y2 = line[0] if y2 - y1 == 0: continue slope = (x2 - x1) / (y2 - y1) angle = np.rad2deg(np.arctan(slope)) if abs(angle) <= 60 and slope < 0: left_coordinate.append([x1, y1, x2, y2]) cv2.line(canny_warped, (x1, y1), (x2, y2), (0, 255, 0), 2) elif abs(angle) <= 60 and slope > 0: right_coordinate.append([x1, y1, x2, y2]) cv2.line(canny_warped, (x1, y1), (x2, y2), (255, 0, 0), 2) except: pass canny_warped = cv2.fillPoly(canny_warped, np.array([[[229, 150], [300, 150], [300, 200], [229, 200]]]), 0) # закрашиваем место под цветную миникарту # processed_image1 = cv2.add(canny_warped, warped_mm) processed_image2 = find_traffic_light(original_image) processed_image = cv2.add(canny_warped, processed_image2) return processed_image
def process_image_lap(original_image): processed_image1 = lap(original_image) processed_image2 = find_traffic_light(original_image) processed_image = cv2.add(processed_image1, processed_image2) return processed_image