1
00:00:02,000 --> 00:00:02,000
Hi, guys.

2
00:00:02,000 --> 00:00:04,000
So this is the predicted file file.

3
00:00:04,000 --> 00:00:10,000
So I have already explained the object tracking code in the previous lectures, so if you want to check

4
00:00:10,000 --> 00:00:12,000
it, do check the previous three lectures.

5
00:00:12,000 --> 00:00:17,000
And I have also explained the counting and speed estimation code in the previous lectures as well.

6
00:00:17,000 --> 00:00:21,000
So if you haven't checked this, lectures do check the previous lectures.

7
00:00:21,000 --> 00:00:27,000
So here I will be only focusing on number of vehicles entering and leaving count.

8
00:00:27,000 --> 00:00:31,000
Okay, so first of all, these are all the required libraries which we have imported.

9
00:00:31,000 --> 00:00:35,000
We have reported the Deepsort module, which you can see over here as well.

10
00:00:35,000 --> 00:00:39,000
And here we have the object counter one and object counter.

11
00:00:39,000 --> 00:00:43,000
So these are the two dictionaries which we have initialized or created over here.

12
00:00:43,000 --> 00:00:49,000
So in object counter one will store the number of vehicles entering and in the object counter I will

13
00:00:49,000 --> 00:00:51,000
store the number of vehicles leaving.

14
00:00:51,000 --> 00:00:55,000
So in object counter one, I will store the number of vehicles entering.

15
00:00:55,000 --> 00:01:02,000
So for example, if the if the four lines passing passes, the lanes for cars, passing passes this

16
00:01:02,000 --> 00:01:08,000
lane so we can say that there are four cars have passed and or four cars have entered and six trucks

17
00:01:08,000 --> 00:01:11,000
have entered or seven bicycles have entered.

18
00:01:11,000 --> 00:01:16,000
So in object counter one, we will store the all the number of vehicles which are entering while in

19
00:01:16,000 --> 00:01:17,000
object counter.

20
00:01:17,000 --> 00:01:19,000
We will store all the vehicles which are leaving.

21
00:01:19,000 --> 00:01:24,000
So in object counter dictionary, we will store the number of vehicles leaving so it can be four cars,

22
00:01:24,000 --> 00:01:29,000
six trucks, three bicycle or three motor cars or three buses as well.

23
00:01:29,000 --> 00:01:35,000
Okay, so object counter will contain the number of vehicles leaving and object counter one will contain

24
00:01:35,000 --> 00:01:36,000
the number of vehicles entry.

25
00:01:36,000 --> 00:01:38,000
And here I have defined the line.

26
00:01:38,000 --> 00:01:41,000
So basically it's this line which I have created.

27
00:01:41,000 --> 00:01:43,000
Let me have just close this image.

28
00:01:43,000 --> 00:01:45,000
Let me show over here as well.

29
00:01:45,000 --> 00:01:48,000
So just opening that image, I'm going to pictures.

30
00:01:48,000 --> 00:01:53,000
And just in short, over here, I will have this.

31
00:01:53,000 --> 00:01:54,000
So just open it.

32
00:01:55,000 --> 00:01:59,000
Okay, so what I'm talking about this line, this green line.

33
00:01:59,000 --> 00:02:02,000
I'm just talking about this green line over here.

34
00:02:02,000 --> 00:02:06,000
So you can see over here that this is the line which.

35
00:02:06,000 --> 00:02:10,000
Okay, so this line I'm talking about this line, this green line over here.

36
00:02:10,000 --> 00:02:11,000
Okay.

37
00:02:11,000 --> 00:02:14,000
So I'm just defining this green line over here in the code.

38
00:02:14,000 --> 00:02:18,000
You can see over here, this is I am defining this green line over here.

39
00:02:19,000 --> 00:02:19,000
Okay?

40
00:02:19,000 --> 00:02:22,000
So here I'm just initializing the Deepsort object tracker.

41
00:02:22,000 --> 00:02:29,000
And here I've just, uh, in the bounding box I received from the Deepsort.

42
00:02:29,000 --> 00:02:35,000
I'm just converting those bounding box coordinates into center coordinates X, y, z, and the form

43
00:02:35,000 --> 00:02:37,000
of width and height over here.

44
00:02:37,000 --> 00:02:42,000
Okay, so here we have this function x, Y2X, y, two x, y, dot left width and height.

45
00:02:42,000 --> 00:02:44,000
So basically, we don't need this function over here.

46
00:02:44,000 --> 00:02:48,000
I've already explained this function in the previous video as well, so you can check it.

47
00:02:48,000 --> 00:02:50,000
And here I'm defining the label.

48
00:02:50,000 --> 00:02:56,000
So if we have the car is directed or you can say if the person is detected, the color of the bounding

49
00:02:56,000 --> 00:02:57,000
box will be this.

50
00:02:57,000 --> 00:03:01,000
And if the car is detected, the color of the bounding box will be this.

51
00:03:01,000 --> 00:03:03,000
I have already explained this in my previous videos.

52
00:03:03,000 --> 00:03:05,000
If you haven't checked it, do check it.

53
00:03:05,000 --> 00:03:09,000
And here we have the draw border function in draw dash border function.

54
00:03:09,000 --> 00:03:14,000
We draw the bounding box and that will add the label text into the our detected objects.

55
00:03:14,000 --> 00:03:17,000
Okay, so this is the draw dash border function.

56
00:03:17,000 --> 00:03:20,000
And here we have the dash box function.

57
00:03:20,000 --> 00:03:24,000
I have already explained all these things as well and I have already explained the Intersect function

58
00:03:24,000 --> 00:03:26,000
in my previous video.

59
00:03:26,000 --> 00:03:28,000
So if you have missed this, do check the previous video.

60
00:03:28,000 --> 00:03:34,000
The new thing, which is not present in the previous videos, is jet dash direction function.

61
00:03:34,000 --> 00:03:36,000
This is the new thing over here.

62
00:03:36,000 --> 00:03:40,000
So here we are defining the get that dash get dash direction function.

63
00:03:40,000 --> 00:03:42,000
So if forward direction if.

64
00:03:43,000 --> 00:03:47,000
So what this function does is so you can see these trails over here.

65
00:03:47,000 --> 00:03:48,000
Okay.

66
00:03:48,000 --> 00:03:55,000
So if the first two trails like we are only focusing on this trail, the number one and this trail,

67
00:03:55,000 --> 00:04:00,000
the number two, I'm just let me just change the color over here and choose some dark.

68
00:04:00,000 --> 00:04:00,000
Okay.

69
00:04:00,000 --> 00:04:06,000
So we are only focusing on this color, this trail, number one color.

70
00:04:06,000 --> 00:04:10,000
And over here and this trail number two, color over here.

71
00:04:10,000 --> 00:04:12,000
So, okay, so these are the trails.

72
00:04:12,000 --> 00:04:17,000
So if this trails direction is in the south direction, like these trails are currently in the south

73
00:04:17,000 --> 00:04:17,000
direction.

74
00:04:17,000 --> 00:04:21,000
You can see over here, these trails direction are in the south direction.

75
00:04:21,000 --> 00:04:25,000
So we can say these trails direction are in the south direction.

76
00:04:25,000 --> 00:04:29,000
And you can say that these trails direction is in the north direction.

77
00:04:29,000 --> 00:04:30,000
Okay.

78
00:04:31,000 --> 00:04:35,000
So we can say that these trails direction is not north direction.

79
00:04:35,000 --> 00:04:35,000
Okay.

80
00:04:35,000 --> 00:04:42,000
So what we are doing is that if the trails direction is in the south direction, we are saying that

81
00:04:42,000 --> 00:04:43,000
these are in the south direction.

82
00:04:43,000 --> 00:04:47,000
And if the trails direction are in the north direction, we are defining the string as a north.

83
00:04:49,000 --> 00:04:50,000
Okay, We are basically here.

84
00:04:50,000 --> 00:04:53,000
We have also defined the east and west.

85
00:04:53,000 --> 00:04:59,000
Basically, if we are doing the traffic count on all the four directions, like there is a round and

86
00:04:59,000 --> 00:05:02,000
the traffic is coming from the four points like that means they knew this.

87
00:05:02,000 --> 00:05:04,000
We will also do this in Windows.

88
00:05:04,000 --> 00:05:09,000
So currently we have the traffic in the from the direction south and from the direction north.

89
00:05:09,000 --> 00:05:10,000
Okay.

90
00:05:10,000 --> 00:05:15,000
But if we have the direction from the east or the west from this side of the traffic as well, then

91
00:05:15,000 --> 00:05:21,000
we can use this east or west, but we are not using it because we are getting the traffic from two sides

92
00:05:21,000 --> 00:05:22,000
north and south.

93
00:05:22,000 --> 00:05:23,000
Okay.

94
00:05:24,000 --> 00:05:24,000
Okay.

95
00:05:24,000 --> 00:05:28,000
Next we will see what we are seeing.

96
00:05:28,000 --> 00:05:30,000
So here we have the glass detector function.

97
00:05:30,000 --> 00:05:35,000
So let me explain you where we are using this get direction function.

98
00:05:36,000 --> 00:05:36,000
Okay.

99
00:05:36,000 --> 00:05:40,000
So here we are using this get direction function which we have created above.

100
00:05:40,000 --> 00:05:43,000
So here we are just calculating the direction of our trails.

101
00:05:43,000 --> 00:05:49,000
So what we are doing is that we currently we are just calculating the direction of these trails, of

102
00:05:49,000 --> 00:05:52,000
these blue lines, these lines which we have.

103
00:05:52,000 --> 00:05:53,000
Okay.

104
00:05:53,000 --> 00:05:58,000
So currently we are getting the direction of this trails using get direction function.

105
00:05:58,000 --> 00:05:58,000
Okay.

106
00:05:58,000 --> 00:06:00,000
And if this trails.

107
00:06:01,000 --> 00:06:01,000
Okay.

108
00:06:01,000 --> 00:06:07,000
So now if this tray like you can see that if this tray, when this tray intersect with this line, you

109
00:06:07,000 --> 00:06:09,000
can see that this green line.

110
00:06:09,000 --> 00:06:09,000
Okay.

111
00:06:09,000 --> 00:06:12,000
When this tray, for example, this coming trail intersect with this line.

112
00:06:14,000 --> 00:06:14,000
Okay.

113
00:06:14,000 --> 00:06:18,000
So we are using the Intersect function which we have created over here.

114
00:06:18,000 --> 00:06:24,000
So you can have shown in the start that when this trail intersect with this line, the color of the

115
00:06:24,000 --> 00:06:25,000
line turns white.

116
00:06:26,000 --> 00:06:31,000
Okay, So you know that when this trail intersect with this line, this color of the line turns from

117
00:06:31,000 --> 00:06:32,000
green to white.

118
00:06:32,000 --> 00:06:34,000
So what this is what I am defining over here.

119
00:06:34,000 --> 00:06:39,000
So when this trail intersect, this line, the color of trails turns white.

120
00:06:39,000 --> 00:06:44,000
And if the direction of the trail is in the south, then we are doing the count of vehicles leaving

121
00:06:44,000 --> 00:06:47,000
and we are just storing those values in the object dash counter dictionary.

122
00:06:47,000 --> 00:06:53,000
And if the direction of the trail is in the north, then we are doing the count of number of vehicles

123
00:06:53,000 --> 00:06:56,000
entering and we are storing this in the object counter one.

124
00:06:56,000 --> 00:06:58,000
Okay, so this is all.

125
00:06:58,000 --> 00:06:59,000
And here we are drawing the trails.

126
00:06:59,000 --> 00:07:02,000
I have also already explained this code in the previous lecture.

127
00:07:02,000 --> 00:07:03,000
Okay?

128
00:07:03,000 --> 00:07:06,000
So you can you can see that in the object counter.

129
00:07:06,000 --> 00:07:08,000
One, we have stored the number of vehicles entering.

130
00:07:08,000 --> 00:07:12,000
So here we are just setting the UI to where we want to display this text.

131
00:07:12,000 --> 00:07:15,000
Like, uh, where we want to display this text.

132
00:07:15,000 --> 00:07:18,000
So we are just setting the this in the UI.

133
00:07:18,000 --> 00:07:24,000
Like I want to display this text over here and number of vehicles leaving text over here.

134
00:07:24,000 --> 00:07:30,000
So we are just setting this in the UI like the number of vehicles leaving and number of vehicles entering.

135
00:07:30,000 --> 00:07:36,000
And I'm just setting this in the UI over here and this is all from this code and I think the script

136
00:07:36,000 --> 00:07:37,000
will have run from here.

137
00:07:37,000 --> 00:07:38,000
Or let me check.

138
00:07:38,000 --> 00:07:39,000
Okay.

139
00:07:39,000 --> 00:07:44,000
So there is still some time for the script to run, but I have shown you the demo output in the start,

140
00:07:44,000 --> 00:07:48,000
but let's wait for the script to run and then I will show these results to you as well.

141
00:07:48,000 --> 00:07:50,000
And then we will end this tutorial.

142
00:07:50,000 --> 00:07:54,000
So I'm just pausing the video and as the script runs, I will show you the output video.

143
00:07:58,000 --> 00:08:02,000
So guys, the script has run successfully and here is our output video.

144
00:08:02,000 --> 00:08:07,000
You can see that that we are going to we are having the number of vehicles entering count and the number

145
00:08:07,000 --> 00:08:09,000
of vehicles leaving count as well.

146
00:08:09,000 --> 00:08:14,000
And our model is working very fine and we are getting the satisfied results as well.

147
00:08:14,000 --> 00:08:16,000
See you all in the next tutorial.

148
00:08:16,000 --> 00:08:22,000
In the next video tutorial, we will just add the speed estimation code in this, uh, already written

149
00:08:22,000 --> 00:08:22,000
script as well.

150
00:08:22,000 --> 00:08:25,000
And then we will proceed further.

151
00:08:25,000 --> 00:08:26,000
So see you all in the next video tutorial.

152
00:08:26,000 --> 00:08:27,000
Till then, bye bye.

153
00:08:30,000 --> 00:08:30,000
About.

