Draw a Forest of Random Tree Objects with Python OpenCV - Classes and OOP Practice for Beginners

  Рет қаралды 49,987

Python Simplified

Python Simplified

Күн бұрын

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:
• Python Classes and Obj...
2. My Draw Shapes with OpenCV Tutorial:
• Draw with OpenCV - No ...
*******************************************
⏰ 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: github.com/MariyaSha/OpenCV_D...
Thanks for watching!
Find me on:
LinkedIn - / mariyasha888
Discord - / discord

Пікірлер: 119
@Swapnil_Shelke
@Swapnil_Shelke 2 жыл бұрын
Happy Teachers Day Maria.. (it's celebrated on 5 sept) for Info - In India, 5th September is celebrated as Teachers' Day as a mark of tribute to the contribution made by teachers to the society. 5th September is the birth anniversary of a great teacher Dr. Sarvepalli Radhakrishnan, who was a staunch believer of education and was a well-known diplomat, scholar, the President of India and above all, a teacher.
@PythonSimplified
@PythonSimplified 2 жыл бұрын
Happy belated teachers' day Swapnil!! 😀😀😀 I had no idea Sep 5th is a holiday!! We're actually celebrating Labour Day today here in Canada, everyone's at home for a long rainy weekend! 😉
@Swapnil_Shelke
@Swapnil_Shelke 2 жыл бұрын
@@PythonSimplified oh wow... That's amazing .... holiday for all workers 😄 🥳 Enjoy your Long weekend ...😊😉😉 And upload next python video early...can't waitto learn new stuffs....🥰
@fun_or_nothing
@fun_or_nothing 2 жыл бұрын
Yes
@bm2911
@bm2911 2 жыл бұрын
@@PythonSimplified 😍😍😍
@cerealport2726
@cerealport2726 2 жыл бұрын
Finally, a video on Python classes that wasn't about creating "users" with the usual "first name", "last name", "age" attributes!! Excellent!
@usmankhawar888
@usmankhawar888 Жыл бұрын
Yeah Man. I was thinking the same.
@ssh17hx0r
@ssh17hx0r 2 жыл бұрын
My daughter is here watching this video with me. She is playing code spark. I said, "Look ril She's a coder too." She once told me "girls don't code" a couple years ago. She like 5 then. I've been fighting that for a while. She is really into it all now. She doesn't do Python yet though. Keep up the great work.
@PythonSimplified
@PythonSimplified 2 жыл бұрын
That's awesome!! Thank you so much for your comment! 😁 I'm actually planning a new "Python for kids" series she might enjoy! I think Python is a great language for the little ones, can't wait to start working on it! 😃
@rafaelaprende
@rafaelaprende Жыл бұрын
Thank you! Maybe the best OOP lesson on the entire KZfaq.
@ericgorder1
@ericgorder1 Жыл бұрын
It went pretty well, I typed along and generated this cool one. I loved the randomness and how to change the parameters with ease. Keep up the good work and your lectures are very exciting and engaging! Thanks!
@stephenlogan162
@stephenlogan162 2 жыл бұрын
Great tutorial, Maria. Clear, thorough and fun. Thank you!
@chalmerditmars7037
@chalmerditmars7037 Жыл бұрын
Great video!!! Your eyes and your expressions show how much joy you get from teaching. You are in your element and help so many people to learn Python. I followed with you to make the first tree with its branches but then just watched the repetition and randomness. I will go back later and follow with code to finish it. Thank you very much!!
@peepleino
@peepleino 2 жыл бұрын
I love the way You explain things so thoroughly and in a very understandable way, with a clear voice. Also, little details, like the order in which You type things, such as closing parentheses or ending a connection before you start inserting content in the middle. And You look stunning!
@rajkirandhiman4208
@rajkirandhiman4208 Жыл бұрын
This tutorial is very helpful. The way she teaches is simple and easy to understand. I am thankful to you :))
@thomasjamesbullock
@thomasjamesbullock Жыл бұрын
Just found your channel. Impressed. Plan on binge watching through holidays.
@carloscosta4713
@carloscosta4713 2 ай бұрын
I am brazilian.... Parabéns pelo excelente trabalho!!! Você é linda e muito didática!!!!!
@bicycleninja1685
@bicycleninja1685 2 жыл бұрын
Most excellent. Thank you! 🙇🏼‍♂️🙏🏼
@Aziz_Ahmad
@Aziz_Ahmad 4 ай бұрын
Thank you for the amazing tutorial playlist! I learned so much and really enjoyed the clear explanations and practical examples. Grateful for the knowledge you shared! video no #3
@ZurioSi
@ZurioSi 2 жыл бұрын
Soon 50k YEEEEY!. Can't wait for 100k, you deserve much more. Thank you like always, amazing and useful video. I'm waiting for the OpenCV face detection app soon xD.
@patawee313
@patawee313 Жыл бұрын
Class in one of a hard concept to understand to implement but you give what it could do. Nice!
@joelsstuff8318
@joelsstuff8318 2 жыл бұрын
I swear I only watch you for your brains and your excellent tutelage. Everything else is just an afterthought.
@concretec0w
@concretec0w 2 жыл бұрын
Great job! Subscribed - thank you Mariya!
@trtlphnx
@trtlphnx 2 жыл бұрын
I've Been Looking Forward to This Lesson; Thanks My Unix-Based Minx, You Are Fantastic ~
@PythonSimplified
@PythonSimplified 2 жыл бұрын
Thank you! have fun! 😀😀😀
@Shawn-cr8ep
@Shawn-cr8ep 2 жыл бұрын
Saw "random" and "forest" thought ML lol. Very neat project, this will be fun for kids to interact with too!
@kazianup4480
@kazianup4480 Жыл бұрын
u really are doing an amazing work. Thank you very much.
@AfricanRisingTechstars
@AfricanRisingTechstars 2 жыл бұрын
Python Simplify indeed you're great 👍
@rrivillox
@rrivillox 2 жыл бұрын
Becareful Bob Ross!!!! Here comes Mariya!!!!! That's awesome. You're the best teacher and developer in whole the world. Congratulations. :8)
@alexandrohdez3982
@alexandrohdez3982 2 жыл бұрын
I do love your videos 👏👏👏
@reddit7372
@reddit7372 2 жыл бұрын
Wonderful!
@thanyaniinnocent940
@thanyaniinnocent940 2 жыл бұрын
I loved the video so much, and I know how a better understanding of classes, attributes and methods. However it was so hard to keep track of code due to the small size of IDE interface.
@404errorpagenotfound.6
@404errorpagenotfound.6 2 жыл бұрын
Been waiting on this one.
@bowboycode2114
@bowboycode2114 2 жыл бұрын
Great job👍
@trevoroware9000
@trevoroware9000 Жыл бұрын
thank you very much for these amazing tutorials, i wanted to ask is it better as a programmer to update to windows 12 or install a linux distribution and which one do you actually use ?
@bobgreen8594
@bobgreen8594 Жыл бұрын
impressive! thanks
@ChaosArtist
@ChaosArtist 2 жыл бұрын
Thanks for the video. I enjoyed coding along. Good to know that Open CV only accepts int values.
@01ALPHA
@01ALPHA 2 жыл бұрын
I want to say thank you to you (Maria) as you are a great Teacher you helped me in understanding classes and and other python stuff , Happy Teachers Day Maria
@PythonSimplified
@PythonSimplified 2 жыл бұрын
Thank you so much! Happy Teachers day! 😁😁😁
@estebanpiccardo6765
@estebanpiccardo6765 2 жыл бұрын
Como me gustaría que traducieran estos tutoriales, están muy buenos! Intento aprender Inglés igual jaja
@DavidLindes
@DavidLindes 4 ай бұрын
Cool stuff. Seems like a potential replacement for Processing... at least if animation is reasonably easy. Anyway, thanks for the tutorial! I shared part 1 with a friend of mine that's looking to do stuff kinda like this. :)
@nczioox1116
@nczioox1116 2 жыл бұрын
Fantastic tutorial! Could this be used to create 3d objects in unity/unreal engine/any 3d environment?
@Its_sarthak_again
@Its_sarthak_again 2 жыл бұрын
Finally got best video 👍👍
@VictorGiustiniPerez_
@VictorGiustiniPerez_ 10 ай бұрын
Nice video! Appreciate it!
@hermysstory8333
@hermysstory8333 Жыл бұрын
Boom! - she said - love it.
@decod3
@decod3 Жыл бұрын
You are awesome please do more of this lessons
@qamarulislam9391
@qamarulislam9391 2 жыл бұрын
Good and beautiful teacher 😍😍
@saurabhtalele1537
@saurabhtalele1537 2 жыл бұрын
best teacher ever
@MrRobot222
@MrRobot222 2 жыл бұрын
Amazing video, thank you! I finally understand the purpose of classes! But, to be a pain, the plural of leaf is leaves. Someone should also really tell the Toronto Maple Leafs Hockey Team, that their name is wrong! 🤣
@DaVinci0963
@DaVinci0963 Жыл бұрын
Thanks Maria!
@S.aliakbar.h7
@S.aliakbar.h7 Жыл бұрын
amazing🙂🙂
@pyoushmadan301
@pyoushmadan301 2 жыл бұрын
Most awaited tutorial , thank you for this amazing video . Nicely explained the importance of classes . Between cheers from India #regularstudent😅
@PythonSimplified
@PythonSimplified 2 жыл бұрын
Thank you so much Piyush! sounds like it was worth the wait! 😉 Cheers from Canada! 😊
@pyoushmadan301
@pyoushmadan301 2 жыл бұрын
@@PythonSimplified yup it was worth waiting
@superkrakend7602
@superkrakend7602 2 жыл бұрын
Возникла такая идея - you can also imitate perspective - use gradient fill for the grass and set trees randomly on different horizontal lines. And maybe little bit more trees on each horizontal line from the bottom to the top to increase density.
@philtoa334
@philtoa334 2 жыл бұрын
So Nice. :)
@giorgosiotis1557
@giorgosiotis1557 2 жыл бұрын
The female mind struck again. Bravo from Athens
@EUROPEANZONE
@EUROPEANZONE Жыл бұрын
Your presentation quality in every class is very good, so I like you very much?
@ellukayou
@ellukayou Жыл бұрын
Nice
@patocuchara01
@patocuchara01 2 жыл бұрын
it was a great tutorial :)
@PythonSimplified
@PythonSimplified 2 жыл бұрын
Thank you Carlos, I'm glad you liked it! 😊
@jr3474
@jr3474 Жыл бұрын
Love ya
@mao13132
@mao13132 Жыл бұрын
Благодарю тебя!
@coffeecuppepsi
@coffeecuppepsi 2 жыл бұрын
Это очень красивые лес ❤️.
@udbhav3760
@udbhav3760 2 жыл бұрын
Nice 👌🌴👏👏
@PythonSimplified
@PythonSimplified 2 жыл бұрын
Thank you! 😊
@hansajajayasanka6270
@hansajajayasanka6270 2 жыл бұрын
Hay maria i am back after long time 😍 i missed some videos
@executerruler3531
@executerruler3531 2 жыл бұрын
Love from nowhere.
@asdasdasdasdasd471
@asdasdasdasdasd471 Жыл бұрын
@saiyamarora3788
@saiyamarora3788 2 жыл бұрын
👍👍👍👍👍👍
@egorkomarov4719
@egorkomarov4719 2 жыл бұрын
Это лучшее, что я видел
@user-ni4ob1gt7e
@user-ni4ob1gt7e 2 жыл бұрын
I want to explain how to create a network through python on Kali or other system, can you do an explanation please
@pllemost8410
@pllemost8410 2 жыл бұрын
Mariya, Do you know Francis Cabrel, the french singer ? In One of his songs , he said.: "...Elle a des yeux Revolver Elle a le regard qui tue Elle a tiré la première..." So you are. A nice and Beautifull teacher.
@PythonSimplified
@PythonSimplified 2 жыл бұрын
Merci Boku PI Lemost!! 😊 I'm not familiar with this song, but the lyrics are beautiful! Thank you! I actually listen to lots of French music! mostly Charlotte Cardin (Quebec French though 😅), Maitre Gims, Stromae, Indila... I absolutely LOVE it! (even though my French skills are quite awful... how very un-Canadian of me 🤣)
@pllemost8410
@pllemost8410 2 жыл бұрын
First at all: About the OpenCV2: some troubles and errors with python 3.8. But ok with python 3.7. Litterally he Said: « She has eyes like a revolver ( gun fire to kill)- when looking at him lovely-; (and) she is the first to fire…. Merci beaucoup… (Beau = bo; coup = Ku.) No skill in englsh but I can understand you if necessary with Google Translater. It is sunny at Paris.
@smalirizvi8026
@smalirizvi8026 2 жыл бұрын
How do you get to know in advance about where I am stuck???? It often happens when I search for a problem and find your *most recent* video addressing it!!
@stardustbiscuits
@stardustbiscuits 2 жыл бұрын
Hi, i made a text based game in Python. It also uses PIL to open some images. But when i converted it from .py to .exe, everything goes well until the part where it has to open the image. It automatically closes when it has to open the image. I tried everything, pyinstaller, auto-py-to-exe and cx_freeze. But it just closes without opening the image. Can you please tell me a solution for this? Thank you 🙂
@shoshanamofaz3012
@shoshanamofaz3012 2 жыл бұрын
When are you doing your flask tutorial? I just made a banking app using flask😎
@PythonSimplified
@PythonSimplified 2 жыл бұрын
That's awesome! 😀 I'm gonna film the Simple Calculator with Flask tutorial sometime this week! should premiere mid-next week 😉
@jsmyers24151
@jsmyers24151 Жыл бұрын
I'm in love. 💘
@rovaherverabe-andriamarozo4083
@rovaherverabe-andriamarozo4083 2 жыл бұрын
I can't teach myself. You are very beautiful and I am frozen to look at your beauty. Very beautiful
@taijenseng
@taijenseng 2 жыл бұрын
Whats the mental framework to code an image?
@WACBlackout
@WACBlackout 2 жыл бұрын
Do you currently program for a company?
@hopi9927
@hopi9927 2 жыл бұрын
Can you create a full course of AI or machine learning for absolute beginner ?
@PythonSimplified
@PythonSimplified 2 жыл бұрын
Hi Ho Pi 😀 Have you seen my ML & AI for beginners playlist? I already have a bunch of beginner-friendly videos on the subject, You can check them out here: kzfaq.info/sun/PLqXS1b2lRpYTpUIEu3oxfhhTuBXmMPppA Good luck and I hope it helps! 😊
@Yachid
@Yachid 2 жыл бұрын
@PythonSimplified
@PythonSimplified 2 жыл бұрын
😁
@tjsonyk
@tjsonyk 2 жыл бұрын
Ждём Flack))
@Sinke_100
@Sinke_100 2 жыл бұрын
cv.imshow dosen't work, but np, using PySimpleGUI
@SaiSai-advertiser
@SaiSai-advertiser Ай бұрын
Maria I love you😍😘
@mmaxeator
@mmaxeator 2 жыл бұрын
Chernobyl popsicle :-)
@dr7615
@dr7615 2 жыл бұрын
Nice.. the concept, however, to my poor feeble mind, of interpreting how to pass information, construct objects, and make such programs run nicely without errors of which I have even less of an ability to understand than the classes and methods alone, is so abstract that it is worse than trying to follow the meaning of what I have written here.
@PythonSimplified
@PythonSimplified 2 жыл бұрын
Hi Dr! 😃 Did you have a chance to watch my other OOP tutorials? I think they are a much better starting point than this one forest of objects: ⭐️ Classes and OOP for beginners: kzfaq.info/get/bejne/nJaEpbB5ntmRhnk.html ⭐️ Practice Classes and OOP with a fun exercise: kzfaq.info/get/bejne/bMlmgbyBz7XDon0.html I hope it helps! OOP is not always easy to grasp - but once you do it feels like getting super powers 😉
@fun_or_nothing
@fun_or_nothing 2 жыл бұрын
Tasty
@darbukadrummer
@darbukadrummer 5 ай бұрын
милашка🍓
@gart2348
@gart2348 2 жыл бұрын
Hai I love you and I am india
@lnthsama
@lnthsama 2 жыл бұрын
🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹
@avazart614
@avazart614 2 жыл бұрын
Думаю все же для рисования больше подходит pygame.
@muddassarjilani6211
@muddassarjilani6211 2 жыл бұрын
kindly make a tutorial on data preparation for panoptic segmentation on custom dataset
@foustcor
@foustcor 2 жыл бұрын
@abdiellara7816
@abdiellara7816 Жыл бұрын
Use the fibonacci numbers to scale the tree 👀
@anjanbora7943
@anjanbora7943 5 ай бұрын
💋
@JarppaGuru
@JarppaGuru 2 жыл бұрын
12:32 keep all original values and make scale = 1 it is same. why need make all smaller then scale 2, but even scale is 2 it look same LOL
@harichalla90
@harichalla90 2 жыл бұрын
Girl talk to me like this, I'm so in love 💕💕🥰🥰
@rovaherverabe-andriamarozo4083
@rovaherverabe-andriamarozo4083 2 жыл бұрын
Je n'arrive pas à m'apprendre. Vous êtes très belle et je suis figé à regarder votre beauté. Vraiment très belle
@JarppaGuru
@JarppaGuru 2 жыл бұрын
13:29 scale 1 not same as original. its 0.5 xD
@shuxiaokai
@shuxiaokai 2 жыл бұрын
Opencv yyds
@PituPonsone
@PituPonsone Жыл бұрын
if (marry_me(you)): return when else: return cry
@johny_doe
@johny_doe 2 жыл бұрын
простите, а какого пола автор?
@iJuce
@iJuce 2 жыл бұрын
why would anyone do this with opencv? its like writing on sticky notes with a paintbrush
@jsmyers24151
@jsmyers24151 Жыл бұрын
Maria! You're beautiful and really intelligent, but you're killing me with the way you pronounce attribute(s). You're pronouncing it like uh-tribute, with the emphasis on tribute. Here in the US, we pronounce it like this: at-tribute, with the emphasis on "at". Sorry to be the "Pronunciation Police", it's part of my OCD, I suppose. One of my many attributes. :0)
@franciszable
@franciszable 2 жыл бұрын
Thanks Maria, opencv is great specially to create user interfaces with mediapipe hands
@stardustbiscuits
@stardustbiscuits 2 жыл бұрын
Hi, i made a text based game in Python. It also uses PIL to open some images. But when i converted it from .py to .exe, everything goes well until the part where it has to open the image. It automatically closes when it has to open the image. I tried everything, pyinstaller, auto-py-to-exe and cx_freeze. But it just closes without opening the image. Can you please tell me a solution for this? Thank you 🙂
@usmankhawar888
@usmankhawar888 Жыл бұрын
I am not sure it helps you but... Same thing happens to me in another way. I made an app in python that contains calender. It works fine but when I converted it into exe by auto-py-to-exe the calender never shows up. I googled it and get the solutions that There are certain libraries whom are connected to anther libraries (sort of inheritence) but most of the py to exe converters dont hooked those parent/child libraries as they are not mentioned in your imports. So I just added these two libraries "from babel.dates import format_date, parse_date, get_day_names, get_month_names" and "from babel.numbers import *". Eventhough they showed greyed in pycharm (as they were not in use) but after that when I converted the app to exe the calender shows up
Python TDD Workflow - Unit Testing Code Example for Beginners
25:33
Python Simplified
Рет қаралды 75 М.
Draw with OpenCV - No more Photoshop! Graphic Design with Python!
14:23
Python Simplified
Рет қаралды 34 М.
Red❤️+Green💚=
00:38
ISSEI / いっせい
Рет қаралды 84 МЛН
DEFINITELY NOT HAPPENING ON MY WATCH! 😒
00:12
Laro Benz
Рет қаралды 63 МЛН
Python Learning Roadmap for Beginners - This is how I learned! - Vlog 4
6:47
OOP Class Inheritance and Private Class Members - Python for Beginners!
16:12
Dictionary Comprehension - Create Complex Data Structures Step by Step
21:58
List Comprehension - BEST Python feature !!! Fast and Efficient
14:51
Python Simplified
Рет қаралды 190 М.
Nature's Incredible ROTATING MOTOR (It’s Electric!) - Smarter Every Day 300
29:37
If __name__ == "__main__" for Python Developers
8:47
Python Simplified
Рет қаралды 391 М.
Python Classes and Objects - OOP for Beginners
8:01
Python Simplified
Рет қаралды 542 М.
Can you solve the paper clip question for 2nd grade students?
11:06
MindYourDecisions
Рет қаралды 20 М.
НЕ БЕРУ APPLE VISION PRO!
0:37
ТЕСЛЕР
Рет қаралды 371 М.
ОБСЛУЖИЛИ САМЫЙ ГРЯЗНЫЙ ПК
1:00
VA-PC
Рет қаралды 2,5 МЛН
Запрещенный Гаджет для Авто с aliexpress 2
0:50
Тимур Сидельников
Рет қаралды 814 М.