WHT

Face Tracking Drone | Drone Face Tracking Pid Using Opencv Pyhton | Tello (2020)

Murtaza's Workshop - Robotics And Ai

Subscribe Here

Likes

378

Views

15,771

Drone Face Tracking Pid Using Opencv Pyhton | Tello (2020)

Transcript:

Hey, everyone, welcome to my channel. In this tutorial, we are going to program a troll to track a face. We will do this using open. CV and apply a PID controller to have smooth movements. So let’s get started, so we are here at our PyCharm projects and we are going to first add our libraries so we will go to settings and we will go to the interpreter and we will add open CV Python, and then we are going to add so you just hit install, and then we are going to add our DGI DJIA cello bye. So this is the drone that we are using. We are using the Taylor drone. Now this is a very good drone that can actually work in the indoor environment and it is very easy to access with open CV. And if you want to really learn open CV and apply to your hardware, then I definitely recommend using the teletran, so there are other methods like controlling it with Raspberry PI and creating your own drone and other packages, so I have found this to be the most easiest method to get started with programming drones, so we are going to install this so we will hit install. I have done both of them and they are good to go so once they are done. We are going to add our two files so we will have one as the main file so face-tracking. Telo, then we are going to add another file, which will be you. Dilys, which will have all our supporting functions so in utilities, we are going to first import our library for the Telo drone. So we will say that from DG. I telepods we are going to import. Porcello, and then we are going to import CV 2 Which is our computer vision library. Now this is in utilities and in face tracking. We are going to add, so we will say that from you till this import everything so so that we don’t have to write utility start every time we need to use a function and then we also need CV to import CV 2 so these are the libraries that we will be needing so the idea is that we are going to perform this in three steps. Now step number one will be basically getting the image from our teller drawn and once we have the image, we are going to find the face that will be the second step and the third step will be to actually track the face using a PID controller so that we send the commands to our motor and to our drone and it moves smoothly so we are going to start off with connecting with our drone, and then we will acquire our image now to do this. We are going to create a function in the utilities and we will call this as initialize. Tell O so we are going to use that. So the first thing we will do is we will name our drone, so we will call it my drone and we will say that it is basically an object. It’s a tell O object–, and then we are going to connect to my drone, so my drone dots connect connect. Yes, so then we have to set all the velocities to zero, so we have four different types of velocities so forwards and backwards. Then we have left and right, then we have up and down, and then we have the rotation, which is your so we will be controlling your, but we have to declare all of them as zero, so we will write here. My drone dot forward, underscore backwards, so we will write back and then we will write Velocity equals zero, and then we will write my drone dots left. Underscore, right underscore will not loss it. T is equals to zero. And then we will write my drone dot up. Underscore down, underscore velocity is equals to zero. And then we will have my drone and dot is your underscore. Velocity is equals to zero. And then we have the journal speed. My drone drone taught speed. It is equals to zero, so that is enough, and then we will print out our battery so that we know how much charge we have left, so we are going to write my drone dot, get battery. Get underscore battery so you can see we have a lot of attributes that we can get and you can try using those as well, but here we just need the batteries over the writes, get battery, and then we are going to write my drone dot stream off stream off the reason we are turning it off at first, so that if by case, we were unable to turn it off in the previous run before it begins, it will turn it off and then it will turn it on again. My drone dot stream on, and that should be enough, and then we are going to return. We turn our drone so yeah, that should be good and let’s call this function in our main file, so we are going to write here that my drone is equals to initial. Stella, and the reason it automatically showed us. This function is because we important everything from here. So once we have done that we will go to our Wi-Fi settings and we will turn on the telephone. Now here you can see that. We have the teller drawn here. I will connect to this and just hit connect automatically button so that it always connects and this will keep going on for a while, but it’s actually already connected. You can right, click and go to the tracking. And there you go and we are getting that. We have 91% battery in our teller drawer. So here it’s already connected and you can see the response. It’s saying, okay, and then it’s showing us the battery and then even stream off was OK and stream on was OK. So this means we have connected and everything is good to go. So the next step would be to actually acquire our image and like before we are going to write a function for this. So in that function, we will define that which drone Are we talking about, and what is the height and the width that we require of this image so we will write here? This is the utilities so we will write here that. Tello, get frame. And then we will write that. We need my drone. We need that object. And then we have to define the width by default. We can put it as 360 by 240 but if the user wants to define, they can define as well so to get the image from our drone, we only need 2 lines of code, so those lines are basically my frame. So this is the frame we are getting is equals to my drone. Dot gets underscore frame, underscore read, and then we are going to write. My frame is equals to my frame dot frame. So these are the two lines that will give us our frame. And once we have that we can change the size of it to whatever the user has requested or to the default sites. So we will write here. IMG is equals to C v2 dot resize, and we will say that we want to resize my frame and the the resizing should be by width and height, so this is the width and height that we want to resize it at, and then we are going to just return our image and that should be enough so now we will go back and we will call this function so here we are going to write a while loop first because we are going to iterate through the frames, so we will write while true, and we will write here that our step 1 is basically image is equals 2 It will tell you get framed. Yeah, and then we have to write my drone and then wait. And then the height, so the width and height, we are going to declare here, so the width and height are let’s say, let’s keep it same 360 by 240 But if you want to change, you can change it here, and then we are going to write C v2 Dot. I am show and we are going to write image and let’s say we are going to write image. OK, and then we are now. One thing that we do have to add is the command to stop it now. This is very important because you are working with the drone and you have to be very careful when it comes to safety. So you have to write if C v2 Dot weight key, and we will add this as one, and then we will say, and now on my website for some reason, it doesn’t show and properly, so I usually write it like this. So if you find it like this, just erase that and write it like this if it doesn’t work and then just put it, it’ll put 0 X F F is equals to our D. And then we will write Q here. This should be double equals. Then we will write here this and we will write my drone now. Even though we are not flying it, we will still write land in case something goes wrong. We can press the Q button and it will stop. So this is just for safety. And is there anything else? I don’t think so, so if I were to run the drone now by the way if you leave it for a while, it will turn off automatically so right now. It turned off. I will turn it on again and we will run it again. Okay, so the teller drone is now connected, so I will right. Click and run now. It will take a while to show the screen, so you have to wait and sometimes it just doesn’t connect properly. You can try it again and it should work so as you can see now. We are getting the frame from our drone and what we can do is if we just wanted to change the size, we can right here, For example, 640 I think it can go maximum to 1 2 8 0 and 720 But this is very. This is a very big image, so I will not recommend this, but still. If you want to see you can use that as well. So there you go now, we are getting a much larger image, but again it will be a bit slower, so keep in mind that there is a delay. When you are actually viewing your image now this is not in the actual processing, so whenever it’s displaying, it’s giving you that delay, it’s not an actual delay, so if you are processing it while running, it should be fine, it’s not a big deal, so this is it for today’s video in the next part, we are going to find our face and then we will find a way how to target only one face, rather than all the different faces that we have detected and then we will get its position so that we can track its position, so stay tuned for that. And if you liked the video, give it a thumbs up and I will see you in the next one.

Wide Resnet | Wide Resnet Explained!

Transcript: [MUSIC] This video will explain the wide residual networks otherwise known as wide ResNet and then frequently abbreviated in papers as wrn - the number of layers - the widening factor, so the headline from this paper is that a simple 16 layer wide. Resnet...

read more