can you please design a flowchart for this code? import cv2 as cv import numpy as np from matplotlib import pyplot as plt def lanesDetection(img): height = img.shape[0] width = img.shape[1] region_of_interest_vertices = [ (200, height), (width/2, height/1.37), (width-300, height) ] gray_img = cv.cvtColor(img, cv.COLOR_RGB2GRAY) edge = cv.Canny(gray_img, 50, 100, apertureSize=3) cropped_image = region_of_interest( edge, np.array([region_of_interest_vertices], np.int32)) lines = cv.HoughLinesP(cropped_image, rho=2, theta=np.pi/180, threshold=50, lines=np.array([]), minLineLength=10, maxLineGap=30) image_with_lines = draw_lines(img, lines) return image_with_lines def region_of_interest(img, vertices): mask = np.zeros_like(img) match_mask_color = (255) cv.fillPoly(mask, vertices, match_mask_color) masked_image = cv.bitwise_and(img, mask) return masked_image def draw_lines(img, lines): img = np.copy(img) blank_image = np.zeros((img.shape[0], img.shape[1], 3), np.uint8) for line in lines: for x1, y1, x2, y2 in line: cv.line(blank_image, (x1, y1), (x2, y2), (0, 255, 0), 2) img = cv.addWeighted(img, 0.8, blank_image, 1, 0.0) return img def videoLanes(): cap = cv.VideoCapture('./img/Lane.mp4') while(cap.isOpened()): ret, frame = cap.read() frame = lanesDetection(frame) cv.imshow('Lanes Detection', frame) if cv.waitKey(1) & 0xFF == ord('q'): break cap.release() cv.destroyAllWindows() if __name__ == "__main__": videoLanes()
can you please design a flowchart for this code? import cv2 as cv import numpy as np from matplotlib import pyplot as plt def lanesDetection(img): height = img.shape[0] width = img.shape[1] region_of_interest_vertices = [ (200, height), (width/2, height/1.37), (width-300, height) ] gray_img = cv.cvtColor(img, cv.COLOR_RGB2GRAY) edge = cv.Canny(gray_img, 50, 100, apertureSize=3) cropped_image = region_of_interest( edge, np.array([region_of_interest_vertices], np.int32)) lines = cv.HoughLinesP(cropped_image, rho=2, theta=np.pi/180, threshold=50, lines=np.array([]), minLineLength=10, maxLineGap=30) image_with_lines = draw_lines(img, lines) return image_with_lines def region_of_interest(img, vertices): mask = np.zeros_like(img) match_mask_color = (255) cv.fillPoly(mask, vertices, match_mask_color) masked_image = cv.bitwise_and(img, mask) return masked_image def draw_lines(img, lines): img = np.copy(img) blank_image = np.zeros((img.shape[0], img.shape[1], 3), np.uint8) for line in lines: for x1, y1, x2, y2 in line: cv.line(blank_image, (x1, y1), (x2, y2), (0, 255, 0), 2) img = cv.addWeighted(img, 0.8, blank_image, 1, 0.0) return img def videoLanes(): cap = cv.VideoCapture('./img/Lane.mp4') while(cap.isOpened()): ret, frame = cap.read() frame = lanesDetection(frame) cv.imshow('Lanes Detection', frame) if cv.waitKey(1) & 0xFF == ord('q'): break cap.release() cv.destroyAllWindows() if __name__ == "__main__": videoLanes()
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
can you please design a flowchart for this code?
import cv2 as cv
import numpy as np
from matplotlib import pyplot as plt
def lanesDetection(img):
height = img.shape[0]
width = img.shape[1]
region_of_interest_vertices = [
(200, height), (width/2, height/1.37), (width-300, height)
]
gray_img = cv.cvtColor(img, cv.COLOR_RGB2GRAY)
edge = cv.Canny(gray_img, 50, 100, apertureSize=3)
cropped_image = region_of_interest(
edge, np.array([region_of_interest_vertices], np.int32))
lines = cv.HoughLinesP(cropped_image, rho=2, theta=np.pi/180,
threshold=50, lines=np.array([]), minLineLength=10, maxLineGap=30)
image_with_lines = draw_lines(img, lines)
return image_with_lines
def region_of_interest(img, vertices):
mask = np.zeros_like(img)
match_mask_color = (255)
cv.fillPoly(mask, vertices, match_mask_color)
masked_image = cv.bitwise_and(img, mask)
return masked_image
def draw_lines(img, lines):
img = np.copy(img)
blank_image = np.zeros((img.shape[0], img.shape[1], 3), np.uint8)
for line in lines:
for x1, y1, x2, y2 in line:
cv.line(blank_image, (x1, y1), (x2, y2), (0, 255, 0), 2)
img = cv.addWeighted(img, 0.8, blank_image, 1, 0.0)
return img
def videoLanes():
cap = cv.VideoCapture('./img/Lane.mp4')
while(cap.isOpened()):
ret, frame = cap.read()
frame = lanesDetection(frame)
cv.imshow('Lanes Detection', frame)
if cv.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv.destroyAllWindows()
if __name__ == "__main__":
videoLanes()
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education