In this article, we will learn how to find the co-ordinates of Contours with the help of OpenCV. Contours are defined as the line joining all the points along the boundary of an image that are having the same intensity. Contours come handy in shape analysis, finding the size of the object of interest, and object detection.
We will be using OpenCV
findContour() function that helps in extracting the contours from the image.
The Co-ordinates of each vertices of a contour is hidden in the contour itself. In this approach, we will be using numpy library to convert all the co-ordinates of a contour into a linear array. This linear array would contain the x and y co-ordinates of each contour. The key point here is that the first co-ordinate in the array would always be the co-ordinate of the topmost vertex and hence could help in detection of orientation of an image.
In the following code, we will be using an image named ‘test.jpg’ to find contours and print the co-ordinates of the vertices on the image itself.
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.
- Find and Draw Contours using OpenCV | Python
- Draw contours on an unstructured triangular grid in Python using Matplotlib
- Ternary contours Plot using Plotly in Python
- Displaying the coordinates of the points clicked on the image using Python-OpenCV
- OpenCV - Facial Landmarks and Face Detection using dlib and OpenCV
- Transition from OpenCV 2 to OpenCV 3.x
- Python | Calculate geographic coordinates of places using google geocoding API
- Python | Reverse Geocoding to get location on a map using geographic coordinates
- Parallel Coordinates Plot using Plotly in Python
- Python | Convert location coordinates to tuple
- Python - Adjacent Coordinates in N dimension
- Python - Group Adjacent Coordinates
- Python - Character coordinates in Matrix
- Python Program to convert complex numbers to Polar coordinates
- Find Circles and Ellipses in an Image using OpenCV | Python
- Python | Create video using multiple images using OpenCV
- Image resizing using Seam carving using OpenCV in Python
- PyQt5 – How to get Label coordinates ?
- Cartooning an Image using OpenCV - Python
- Real-Time Edge Detection using OpenCV in Python | Canny edge detection method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Mahantesh