Draw Multiple Rectangles in Image using Python-Opencv
In this article, we are going to see how to draw multiple rectangles in an image using Python and OpenCV.
- imread(): In the OpenCV, the cv2.imread() function is used to read an image in Python.
Syntax: cv2.imread(path_of_image, flag)
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
- rectangle(): In the OpenCV, the cv2.rectangle function is used to draw a rectangle on the image in Python.
Syntax: cv2.rectangle(image, starting_coordinate, ending_coordinate, color, thickness)
- imshow(): In the OpenCV, the cv2.imshow() function is used to display an image in Python.
Syntax: cv2.imshow(window_name, image)
- waitKey(): In the OpenCV, the cv2.waitkey() function allows you to wait for a specific time in milliseconds.
- destroyAllWindows(): In the OpenCV, the destroyAllWindows() function is used to closes all the windows created using the OpenCV methods.
Below is the implementation: