Hi, guys.
So this is the predicted file file.
So I have already explained the object tracking code in the previous lectures, so if you want to check
it, do check the previous three lectures.
And I have also explained the counting and speed estimation code in the previous lectures as well.
So if you haven't checked this, lectures do check the previous lectures.
So here I will be only focusing on number of vehicles entering and leaving count.
Okay, so first of all, these are all the required libraries which we have imported.
We have reported the Deepsort module, which you can see over here as well.
And here we have the object counter one and object counter.
So these are the two dictionaries which we have initialized or created over here.
So in object counter one will store the number of vehicles entering and in the object counter I will
store the number of vehicles leaving.
So in object counter one, I will store the number of vehicles entering.
So for example, if the if the four lines passing passes, the lanes for cars, passing passes this
lane so we can say that there are four cars have passed and or four cars have entered and six trucks
have entered or seven bicycles have entered.
So in object counter one, we will store the all the number of vehicles which are entering while in
object counter.
We will store all the vehicles which are leaving.
So in object counter dictionary, we will store the number of vehicles leaving so it can be four cars,
six trucks, three bicycle or three motor cars or three buses as well.
Okay, so object counter will contain the number of vehicles leaving and object counter one will contain
the number of vehicles entry.
And here I have defined the line.
So basically it's this line which I have created.
Let me have just close this image.
Let me show over here as well.
So just opening that image, I'm going to pictures.
And just in short, over here, I will have this.
So just open it.
Okay, so what I'm talking about this line, this green line.
I'm just talking about this green line over here.
So you can see over here that this is the line which.
Okay, so this line I'm talking about this line, this green line over here.
Okay.
So I'm just defining this green line over here in the code.
You can see over here, this is I am defining this green line over here.
Okay?
So here I'm just initializing the Deepsort object tracker.
And here I've just, uh, in the bounding box I received from the Deepsort.
I'm just converting those bounding box coordinates into center coordinates X, y, z, and the form
of width and height over here.
Okay, so here we have this function x, Y2X, y, two x, y, dot left width and height.
So basically, we don't need this function over here.
I've already explained this function in the previous video as well, so you can check it.
And here I'm defining the label.
So if we have the car is directed or you can say if the person is detected, the color of the bounding
box will be this.
And if the car is detected, the color of the bounding box will be this.
I have already explained this in my previous videos.
If you haven't checked it, do check it.
And here we have the draw border function in draw dash border function.
We draw the bounding box and that will add the label text into the our detected objects.
Okay, so this is the draw dash border function.
And here we have the dash box function.
I have already explained all these things as well and I have already explained the Intersect function
in my previous video.
So if you have missed this, do check the previous video.
The new thing, which is not present in the previous videos, is jet dash direction function.
This is the new thing over here.
So here we are defining the get that dash get dash direction function.
So if forward direction if.
So what this function does is so you can see these trails over here.
Okay.
So if the first two trails like we are only focusing on this trail, the number one and this trail,
the number two, I'm just let me just change the color over here and choose some dark.
Okay.
So we are only focusing on this color, this trail, number one color.
And over here and this trail number two, color over here.
So, okay, so these are the trails.
So if this trails direction is in the south direction, like these trails are currently in the south
direction.
You can see over here, these trails direction are in the south direction.
So we can say these trails direction are in the south direction.
And you can say that these trails direction is in the north direction.
Okay.
So we can say that these trails direction is not north direction.
Okay.
So what we are doing is that if the trails direction is in the south direction, we are saying that
these are in the south direction.
And if the trails direction are in the north direction, we are defining the string as a north.
Okay, We are basically here.
We have also defined the east and west.
Basically, if we are doing the traffic count on all the four directions, like there is a round and
the traffic is coming from the four points like that means they knew this.
We will also do this in Windows.
So currently we have the traffic in the from the direction south and from the direction north.
Okay.
But if we have the direction from the east or the west from this side of the traffic as well, then
we can use this east or west, but we are not using it because we are getting the traffic from two sides
north and south.
Okay.
Next we will see what we are seeing.
So here we have the glass detector function.
So let me explain you where we are using this get direction function.
Okay.
So here we are using this get direction function which we have created above.
So here we are just calculating the direction of our trails.
So what we are doing is that we currently we are just calculating the direction of these trails, of
these blue lines, these lines which we have.
Okay.
So currently we are getting the direction of this trails using get direction function.
Okay.
And if this trails.
Okay.
So now if this tray like you can see that if this tray, when this tray intersect with this line, you
can see that this green line.
Okay.
When this tray, for example, this coming trail intersect with this line.
Okay.
So we are using the Intersect function which we have created over here.
So you can have shown in the start that when this trail intersect with this line, the color of the
line turns white.
Okay, So you know that when this trail intersect with this line, this color of the line turns from
green to white.
So what this is what I am defining over here.
So when this trail intersect, this line, the color of trails turns white.
And if the direction of the trail is in the south, then we are doing the count of vehicles leaving
and we are just storing those values in the object dash counter dictionary.
And if the direction of the trail is in the north, then we are doing the count of number of vehicles
entering and we are storing this in the object counter one.
Okay, so this is all.
And here we are drawing the trails.
I have also already explained this code in the previous lecture.
Okay?
So you can you can see that in the object counter.
One, we have stored the number of vehicles entering.
So here we are just setting the UI to where we want to display this text.
Like, uh, where we want to display this text.
So we are just setting the this in the UI.
Like I want to display this text over here and number of vehicles leaving text over here.
So we are just setting this in the UI like the number of vehicles leaving and number of vehicles entering.
And I'm just setting this in the UI over here and this is all from this code and I think the script
will have run from here.
Or let me check.
Okay.
So there is still some time for the script to run, but I have shown you the demo output in the start,
but let's wait for the script to run and then I will show these results to you as well.
And then we will end this tutorial.
So I'm just pausing the video and as the script runs, I will show you the output video.
So guys, the script has run successfully and here is our output video.
You can see that that we are going to we are having the number of vehicles entering count and the number
of vehicles leaving count as well.
And our model is working very fine and we are getting the satisfied results as well.
See you all in the next tutorial.
In the next video tutorial, we will just add the speed estimation code in this, uh, already written
script as well.
And then we will proceed further.
So see you all in the next video tutorial.
Till then, bye bye.
About.