Title | : | Draw a Forest of Random Tree Objects with Python OpenCV - Classes and OOP Practice for Beginners |
Duration | : | 24:36 |
Viewed | : | 49,412 |
Published | : | 06-09-2021 |
Source | : | Youtube |
In this tutorial, we will practice the principles of Object-Oriented Programming and draw a forest of unique tree objects. We will first create a Tree class and then we will replicate it in different locations, sizes and colours. We will also include a very large degree of randomness in our code, so that each time our program runs - a brand new forest with brand new trees is created! 🤩🤩🤩 🛑🤚 HAVE YOU WATCHED ✋🛑 ******************************************* 1. My OOP and Classes Tutorial: https://youtu.be/f0TrMH9s-VE 2. My Draw Shapes with OpenCV Tutorial: https://youtu.be/PtvN8ad9N3g ******************************************* ⏰ TIMESTAMPS ⏰ 00:00 - intro 00:16 - starter code overview 01:01 - create a class 01:22 - class attributes 02:07 - class methods 03:40 - call class 05:40 - relative coordinates 06:22 - draw object 09:04 - scale object 13:35 - fancy design tricks 14:40 - draw step repeat objects 16:04 - draw objects at random location 19:47 - draw with random colors 24:14 - coming soon and thank you! 🐍 STARTER CODE 🐍 ************************************************ import numpy as np import cv2 as cv import random # general parameters width = 900 height = 600 n_trees = 30 ground_level = height-100 # colours green, light_green, brown = (40,185,40),(25,220,0),(30,65,155) # blank image bg = np.zeros((height, width, 3), dtype=np.uint8) # draw background cv.rectangle(bg,(width,0), (0, ground_level), (255,225,95), -1) cv.rectangle(bg,(width, ground_level), (0, height), green, -1) # *************** # YOUR CODE GOES HERE # *************** #display image cv.imshow('forest of objects', bg) cv.waitKey(0) cv.destroyAllWindows() ************************************************ 🐍 END OF STARTER CODE 🐍 Didn't feel like coding along? 🙃 Get the complete code from my Github: https://github.com/MariyaSha/OpenCV_DrawImages/blob/main/completeCode_OpenCVForest.ipynb Thanks for watching! Find me on: LinkedIn - https://linkedin.com/in/mariyasha888/ Discord - https://discord.gg/WeTz5A2FfS
![]() |
Python TDD Workflow - Unit Testing Code Example... 25:33 - 74,816 |
![]() |
If name == " main " for Python Developers 08:47 - 384,640 |
![]() |
Draw with OpenCV - No more Photoshop! Graphic D... 14:23 - 33,835 |
![]() |
Python Object Oriented Programming (OOP) - For ... 53:06 - 3,340,074 |
![]() |
List Comprehension - BEST Python feature !!! Fa... 14:51 - 188,452 |
![]() |
Python Classes and Objects - OOP for Beginners 08:01 - 537,217 |
![]() |
Functions vs Classes: When to Use Which and Why? 10:49 - 145,113 |
![]() |
Dictionary Comprehension - Create Complex Data ... 21:58 - 87,392 |