Prerequisite: Geometric shapes using OpenCV
Given three vertices of a triangle, write a Python program to find the centroid of the triangle and then draw the triangle with its centroid on a black window using OpenCV.
Input: (100, 200) (50, 50) (300, 100) Output: (150, 116)
Create a black window with three color channels with resolution 400 x 300. Draw three lines which are passing through the given points using the inbuilt line function of the OpenCV. It will create a triangle on the black window. Find the centroid of the triangle using the following simple formula.
Draw this centroid on the black window using circle function of OpenCV with zero thickness.
Below is the implementation of the above approach:
- Draw geometric shapes on images using OpenCV
- Python | Draw rectangular shape and extract objects using OpenCV
- Find and Draw Contours using OpenCV | Python
- Python | Create video using multiple images using OpenCV
- Cartooning an Image using OpenCV - Python
- Real-Time Edge Detection using OpenCV in Python | Canny edge detection method
- OpenCV Python Program to analyze an image using Histogram
- Detection of a specific color(blue here) using OpenCV with Python
- Python Program to detect the edges of an image using OpenCV | Sobel edge detection method
- Erosion and Dilation of images using OpenCV in python
- Template matching using OpenCV in Python
- Stitching input images (panorama) using OpenCV with C++
- Image Processing using OpenCV in Java | Set 13 (Brightness Enhancement)
- Image Processing using OpenCV in Java | Set 14 ( Sharpness Enhancement )
- OpenCV: Segmentation using Thresholding
- Addition and Blending of images using OpenCV in Python
- Reading an image in OpenCV using Python
- Python | Play a video in reverse mode using OpenCV
- Python | Program to extract frames using OpenCV
- Opening multiple color windows to capture using OpenCV in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.