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
- Find and Draw Contours using OpenCV | Python
- Python | Draw rectangular shape and extract objects using OpenCV
- Python PIL | ImageDraw.Draw.arc()
- Python PIL | ImageDraw.Draw.ellipse()
- Draw Sudan Flag using MATLAB
- Draw Indian Flag using matlab
- Draw Sweden Flag using matlab
- Python PIL |ImageDraw.Draw.multiline_text()
- Python PIL | ImageDraw.Draw.rectangle()
- Draw Kuwait Flag using MATLAB
- How to draw Japan flag using MATLAB
- Python PIL | ImageDraw.Draw.pieslice()
- Python PIL | ImageDraw.Draw.text()
- Python PIL | ImageDraw.Draw.multiline_textsize()
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.