1
00:00:02,000 --> 00:00:03,000
Hello everyone.

2
00:00:03,000 --> 00:00:10,000
In this video tutorial we will use YOLO V8 with Deepsort object tracking to count the vehicles going

3
00:00:10,000 --> 00:00:13,000
in the north, south, east and west direction.

4
00:00:13,000 --> 00:00:19,000
We will count the number of cars, buses and trucks going in each of the direction.

5
00:00:19,000 --> 00:00:22,000
So let's get started in front of you.

6
00:00:22,000 --> 00:00:26,000
You can see the demo output video, which in front of you you can see over here.

7
00:00:26,000 --> 00:00:28,000
So you can see that this is the north direction.

8
00:00:28,000 --> 00:00:33,000
This is the south direction over here and this is the east and this is the west direction.

9
00:00:33,000 --> 00:00:33,000
Okay.

10
00:00:33,000 --> 00:00:39,000
So whenever the car or any other vehicle intersect with this line so you can see the here we see the

11
00:00:39,000 --> 00:00:41,000
increment like in each direction.

12
00:00:41,000 --> 00:00:46,000
Two cars have passed in past three trucks have passed in the west direction.

13
00:00:46,000 --> 00:00:48,000
One truck has passed in the north direction.

14
00:00:48,000 --> 00:00:51,000
We can see the one truck has also passed in the south direction.

15
00:00:51,000 --> 00:00:54,000
We can also see that one truck has passed.

16
00:00:54,000 --> 00:00:59,000
So let me show you the Direction Compass first and then we can go into further details.

17
00:01:00,000 --> 00:01:00,000
Okay.

18
00:01:00,000 --> 00:01:04,000
So this is the Direction Compass we have above is the north direction.

19
00:01:04,000 --> 00:01:05,000
This is the south direction.

20
00:01:05,000 --> 00:01:08,000
This is the east direction and this is the west direction.

21
00:01:08,000 --> 00:01:09,000
Okay?

22
00:01:09,000 --> 00:01:15,000
So just keep this direction compass in your mind and let's go back towards the output video demo.

23
00:01:15,000 --> 00:01:15,000
So.

24
00:01:17,000 --> 00:01:20,000
You can see that this is a north direction we have.

25
00:01:20,000 --> 00:01:23,000
This is a south and this is a east and this is the west.

26
00:01:23,000 --> 00:01:30,000
So whenever any bigger like truck, car or bus intersect with this line over here or over here or over

27
00:01:30,000 --> 00:01:33,000
here, this green line, you can see that these green lines over here.

28
00:01:33,000 --> 00:01:40,000
So when any vehicles intersect with this line, for example, if the vehicles enters going in the north

29
00:01:40,000 --> 00:01:46,000
direction, for example, if the vehicle intersect with this line, this is in the north direction.

30
00:01:46,000 --> 00:01:48,000
So we have a count in the north direction.

31
00:01:48,000 --> 00:01:53,000
Like if the truck intersect with this line, then we can say that one truck has passed.

32
00:01:53,000 --> 00:01:53,000
Okay?

33
00:01:53,000 --> 00:01:57,000
Or if the car intersect with this line, this is the north direction.

34
00:01:57,000 --> 00:02:00,000
So we can say that the car has passed over here.

35
00:02:00,000 --> 00:02:01,000
Okay?

36
00:02:01,000 --> 00:02:04,000
So in this way, we do the direction count over here.

37
00:02:04,000 --> 00:02:10,000
So if you can see over here, I've just added an image over here.

38
00:02:10,000 --> 00:02:12,000
So let me just make it a bit short.

39
00:02:12,000 --> 00:02:13,000
Okay.

40
00:02:13,000 --> 00:02:15,000
So as you can see over here.

41
00:02:16,000 --> 00:02:18,000
This is a line over green line over here.

42
00:02:18,000 --> 00:02:20,000
So here we can see that truck.

43
00:02:20,000 --> 00:02:20,000
Okay.

44
00:02:20,000 --> 00:02:24,000
So if I select this as a pick, okay.

45
00:02:24,000 --> 00:02:26,000
And just select a red color from here.

46
00:02:26,000 --> 00:02:27,000
Okay.

47
00:02:27,000 --> 00:02:29,000
And okay, that's fine.

48
00:02:29,000 --> 00:02:30,000
Let's select the red color.

49
00:02:31,000 --> 00:02:31,000
Okay.

50
00:02:31,000 --> 00:02:33,000
So you can see this trails line.

51
00:02:33,000 --> 00:02:37,000
Okay, let me just make it a bit more brighter.

52
00:02:37,000 --> 00:02:37,000
A bit.

53
00:02:38,000 --> 00:02:38,000
Okay.

54
00:02:38,000 --> 00:02:39,000
I think this will work.

55
00:02:39,000 --> 00:02:39,000
Okay.

56
00:02:39,000 --> 00:02:41,000
So you can see this trails line over here.

57
00:02:42,000 --> 00:02:42,000
Okay.

58
00:02:42,000 --> 00:02:44,000
You can you see this trails line.

59
00:02:44,000 --> 00:02:46,000
Okay, So this is the trails line over here.

60
00:02:46,000 --> 00:02:52,000
So when this trails intersect with this green line, okay, When this trail intersect with this green

61
00:02:52,000 --> 00:02:56,000
line, then we can say, for example, this truck is going in the west direction.

62
00:02:56,000 --> 00:02:58,000
Okay, this is a north.

63
00:02:58,000 --> 00:02:59,000
So sorry.

64
00:02:59,000 --> 00:03:00,000
This is going the south direction.

65
00:03:00,000 --> 00:03:01,000
Okay?

66
00:03:01,000 --> 00:03:04,000
This is a south and this is the east direction.

67
00:03:05,000 --> 00:03:07,000
And this is the west direction.

68
00:03:07,000 --> 00:03:07,000
Okay.

69
00:03:08,000 --> 00:03:13,000
So as this truck is going in the south direction, so when this cart trade intersects with this green

70
00:03:13,000 --> 00:03:21,000
line, then we can have an increment over here like you can see over here, like south direction, that

71
00:03:21,000 --> 00:03:25,000
truck goes into the south direction and we can say, one, that truck will get increment.

72
00:03:25,000 --> 00:03:27,000
Let me show you this part of the code.

73
00:03:27,000 --> 00:03:29,000
For example, just let me show you this.

74
00:03:29,000 --> 00:03:34,000
So currently you can see that we don't have any vehicle going in the south direction.

75
00:03:34,000 --> 00:03:35,000
Okay.

76
00:03:35,000 --> 00:03:38,000
Like south direction and the west direction is empty.

77
00:03:38,000 --> 00:03:40,000
So we will see the west direction in the last part.

78
00:03:40,000 --> 00:03:44,000
But currently focus on this only the south direction.

79
00:03:44,000 --> 00:03:44,000
Okay.

80
00:03:44,000 --> 00:03:45,000
Which is over here.

81
00:03:45,000 --> 00:03:47,000
So let me play this video.

82
00:03:47,000 --> 00:03:48,000
Okay.

83
00:03:48,000 --> 00:03:50,000
So you can see just focus over here.

84
00:03:50,000 --> 00:03:51,000
Okay.

85
00:03:51,000 --> 00:03:53,000
So let me just play this video.

86
00:03:53,000 --> 00:03:53,000
Okay.

87
00:03:53,000 --> 00:03:54,000
So, okay.

88
00:03:54,000 --> 00:03:55,000
Okay.

89
00:03:55,000 --> 00:03:56,000
And let me just.

90
00:03:56,000 --> 00:04:02,000
Okay, so when you see that when this train line, this brown line intersect with this green line,

91
00:04:02,000 --> 00:04:06,000
we can say that in the south direction, one truck has passed.

92
00:04:06,000 --> 00:04:06,000
Okay.

93
00:04:06,000 --> 00:04:13,000
So when this green or brown line, you can see brown line intersect with this green line, then we have

94
00:04:13,000 --> 00:04:15,000
an increment over here in the south direction.

95
00:04:15,000 --> 00:04:17,000
One truck has passed.

96
00:04:17,000 --> 00:04:17,000
Okay.

97
00:04:17,000 --> 00:04:20,000
Now let's see what the west direction as well.

98
00:04:20,000 --> 00:04:22,000
Okay, So just go over here.

99
00:04:22,000 --> 00:04:23,000
Okay.

100
00:04:23,000 --> 00:04:26,000
So now you can see that this is going the east direction.

101
00:04:26,000 --> 00:04:27,000
Okay.

102
00:04:27,000 --> 00:04:28,000
In the east direction.

103
00:04:28,000 --> 00:04:29,000
Currently we have one truck.

104
00:04:29,000 --> 00:04:29,000
Okay.

105
00:04:30,000 --> 00:04:32,000
As this is an east direction.

106
00:04:32,000 --> 00:04:33,000
Okay, so.

107
00:04:34,000 --> 00:04:34,000
Okay.

108
00:04:34,000 --> 00:04:38,000
So you can see that this when this truck has passed in this direction is direction.

109
00:04:38,000 --> 00:04:39,000
So we can say that.

110
00:04:39,000 --> 00:04:40,000
See that?

111
00:04:40,000 --> 00:04:43,000
Currently you can see that we have one truck over here.

112
00:04:43,000 --> 00:04:43,000
Okay.

113
00:04:43,000 --> 00:04:45,000
So we have one truck over here.

114
00:04:45,000 --> 00:04:52,000
So we let's say when this truck passes this line, you can see the truck count increases to two.

115
00:04:52,000 --> 00:04:52,000
Okay.

116
00:04:52,000 --> 00:04:54,000
So in this way, it works.

117
00:04:54,000 --> 00:04:57,000
So like now this car is passing this line.

118
00:04:57,000 --> 00:05:00,000
So now we can see that that truck car count is also increasing.

119
00:05:00,000 --> 00:05:04,000
Plus, let's see the east direction.

120
00:05:04,000 --> 00:05:04,000
Okay.

121
00:05:05,000 --> 00:05:05,000
Okay.

122
00:05:05,000 --> 00:05:08,000
Let me show you the one other direction, West direction.

123
00:05:08,000 --> 00:05:08,000
Okay.

124
00:05:08,000 --> 00:05:14,000
So you can see that when this country we don't have any vehicle going into the west direction, basically,

125
00:05:14,000 --> 00:05:16,000
this is the west direction we have.

126
00:05:16,000 --> 00:05:16,000
Okay.

127
00:05:16,000 --> 00:05:23,000
So when this truck, you can say that this intersect with this trace line, like this brown line intersect

128
00:05:23,000 --> 00:05:29,000
with this green line truck, this brown line intersect with this green line, Then we can see the increment

129
00:05:29,000 --> 00:05:30,000
over here in the west direction.

130
00:05:30,000 --> 00:05:32,000
We can see that one truck has passed.

131
00:05:32,000 --> 00:05:35,000
So, okay, just going a bit back.

132
00:05:35,000 --> 00:05:36,000
Okay.

133
00:05:36,000 --> 00:05:42,000
So you can say that when this brown line intersect with this green line, we can see in the west direction

134
00:05:42,000 --> 00:05:43,000
one truck has passed.

135
00:05:43,000 --> 00:05:44,000
Okay?

136
00:05:44,000 --> 00:05:46,000
So in this way, all this mechanism work.

137
00:05:46,000 --> 00:05:49,000
Now, you can say that this is the end result in the east direction.

138
00:05:49,000 --> 00:05:51,000
Two cars, three trucks have passed.

139
00:05:51,000 --> 00:05:57,000
So this is the east direction we have and in the north direction, which is over here, one truck has

140
00:05:57,000 --> 00:05:59,000
passed in the south direction.

141
00:05:59,000 --> 00:06:02,000
One truck also has passed, which is over here and in the west direction.

142
00:06:02,000 --> 00:06:05,000
One truck has also passed, which is over here.

143
00:06:05,000 --> 00:06:10,000
So let me show you again like you can please focus on this brown line over here so you can see that

144
00:06:10,000 --> 00:06:15,000
when this brown line intersect with this green line, you can see that we have an increment in the truck

145
00:06:15,000 --> 00:06:17,000
like one truck has passed.

146
00:06:17,000 --> 00:06:22,000
So let's go towards the CoLab file, CoLab code part and further explore the thing.

147
00:06:22,000 --> 00:06:24,000
And let me explain you the complete code as well.

148
00:06:24,000 --> 00:06:28,000
Like how can you implement this project on your side as well?

149
00:06:28,000 --> 00:06:30,000
So let's move towards the code part.

150
00:06:31,000 --> 00:06:34,000
So here we have the complete code for this project.

151
00:06:34,000 --> 00:06:37,000
I will be sharing this complete code with you as well.

152
00:06:37,000 --> 00:06:38,000
So.

153
00:06:39,000 --> 00:06:40,000
Most of all, we are use in this project.

154
00:06:40,000 --> 00:06:44,000
We are using the sword object tracking GitHub repo.

155
00:06:44,000 --> 00:06:51,000
Let me open this first, so just copy this link from here and just open a new window here and just and

156
00:06:51,000 --> 00:06:52,000
click on enter.

157
00:06:52,000 --> 00:06:55,000
So this is the GitHub repo.

158
00:06:55,000 --> 00:06:57,000
Yolo v eight Deepsort Object tracking repo.

159
00:06:58,000 --> 00:07:00,000
Which I am using in this project.

160
00:07:00,000 --> 00:07:04,000
So this is I have created this GitHub repo, so you can just.

161
00:07:05,000 --> 00:07:09,000
I will be sharing this GitHub repo link with you so you can easily access this repo as well.

162
00:07:09,000 --> 00:07:09,000
Okay.

163
00:07:09,000 --> 00:07:13,000
So here already the steps are provided to run the code.

164
00:07:13,000 --> 00:07:18,000
So I have just followed the same steps in the Google CoLab notebook as well and I will share this notebook

165
00:07:18,000 --> 00:07:19,000
file with you as well.

166
00:07:19,000 --> 00:07:20,000
Okay.

167
00:07:20,000 --> 00:07:26,000
So first of all, just let me change this disconnect and delete runtime because I've already run this

168
00:07:26,000 --> 00:07:29,000
script previously, so let me do it from the start.

169
00:07:29,000 --> 00:07:33,000
So just connecting it again over here.

170
00:07:33,000 --> 00:07:38,000
So okay, so before running the script, please make sure that you have selected the runtime as hardware

171
00:07:38,000 --> 00:07:39,000
accelerator as GPU.

172
00:07:39,000 --> 00:07:43,000
Okay, then you just need to clone the GitHub repo in the first step.

173
00:07:44,000 --> 00:07:50,000
So here I'm just cloning the GitHub repo, which you can see over here, so this might take a few seconds.

174
00:07:50,000 --> 00:07:50,000
Okay.

175
00:07:50,000 --> 00:07:56,000
So now the repo is cloned and you can see the GitHub repo over here by the name of V8 Deep Sword object

176
00:07:56,000 --> 00:07:58,000
tracking GitHub repo.

177
00:07:58,000 --> 00:08:06,000
Now we now if we see that what our present working directory is so we can just write b d this shows

178
00:08:06,000 --> 00:08:08,000
us what is our present working directory.

179
00:08:08,000 --> 00:08:12,000
So our present working directory is this file section.

180
00:08:12,000 --> 00:08:18,000
So we need to set our present working directory or the current directory as this cloned folder.

181
00:08:18,000 --> 00:08:22,000
So just copy this path over here and write CD percentage.

182
00:08:22,000 --> 00:08:28,000
CD cd means current directory and just paste this path over here and just click on Enter.

183
00:08:29,000 --> 00:08:34,000
So now this spawned clone folder will be set to as our current directory.

184
00:08:34,000 --> 00:08:37,000
So now this clone folder is set to our current directory.

185
00:08:37,000 --> 00:08:40,000
So with the folder which we have cloned is our no current directory.

186
00:08:40,000 --> 00:08:44,000
In the next step we need to install all the required libraries or the dependencies.

187
00:08:44,000 --> 00:08:49,000
If you skip this step, then if you run the training validation or prediction step, then you might

188
00:08:49,000 --> 00:08:51,000
face that error that the following library.

189
00:08:51,000 --> 00:08:57,000
For example, Hydra library, Matplotlib library, Seaborn library or any other library is not installed,

190
00:08:57,000 --> 00:09:02,000
so it's necessary to install all the required libraries by installing all the dependencies.

191
00:09:02,000 --> 00:09:06,000
So if I run this cell, it will install all the required libraries.

192
00:09:06,000 --> 00:09:10,000
Or you can say the dependencies will get installed by if you run this cell.

193
00:09:11,000 --> 00:09:14,000
Okay, so this might take few seconds to execute.

194
00:09:14,000 --> 00:09:21,000
So I'm just installing all the required libraries or the dependencies required to run this project.

195
00:09:21,000 --> 00:09:22,000
Okay.

196
00:09:22,000 --> 00:09:24,000
So this might take few more seconds.

197
00:09:24,000 --> 00:09:25,000
So let's see.

198
00:09:25,000 --> 00:09:28,000
But it will be installed in few seconds.

199
00:09:28,000 --> 00:09:32,000
Or like you can see markdown jinja2 library request library.

200
00:09:32,000 --> 00:09:33,000
They are all getting installed.

201
00:09:33,000 --> 00:09:36,000
So if you've not run this cell then you will definitely face the error.

202
00:09:36,000 --> 00:09:41,000
When you run the training, validation or prediction script that the following library is not installed.

203
00:09:41,000 --> 00:09:42,000
Okay.

204
00:09:42,000 --> 00:09:47,000
So now as we are implementing detection in this step, like in this project, like detection and tracking

205
00:09:47,000 --> 00:09:56,000
in this project, so just go to ultralytics, YOLO V8 and go to the detect folder and set this folder

206
00:09:56,000 --> 00:09:57,000
as your current directory.

207
00:09:57,000 --> 00:09:58,000
Okay.

208
00:09:58,000 --> 00:10:05,000
So just copy path from here and set the detect folder as your current directory because we are performing

209
00:10:05,000 --> 00:10:08,000
an object detection and tracking in this project.

210
00:10:08,000 --> 00:10:08,000
Okay.

211
00:10:08,000 --> 00:10:14,000
So in we have set the detect folder as our current directory because here we have that train predict

212
00:10:14,000 --> 00:10:16,000
and validation.py files.

213
00:10:17,000 --> 00:10:21,000
So now, as in this project, we are using our deepsort for object tracking.

214
00:10:21,000 --> 00:10:25,000
So I will install all the deepsort files from the.

215
00:10:25,000 --> 00:10:30,000
I have already placed the Deepsort files into my google drive, so I'm just downloading the deepsort

216
00:10:30,000 --> 00:10:36,000
files from the Google drive into my Google CoLab notebook, so it might take few seconds to download

217
00:10:36,000 --> 00:10:40,000
the Deepsort files from the Google Drive into the Google CoLab notebook.

218
00:10:40,000 --> 00:10:46,000
So I have downloaded currently the zip file so you can see over here in the detect folder I have the

219
00:10:46,000 --> 00:10:52,000
Deepsort PyTorch zip file over here, so I will just unzip it from here.

220
00:10:52,000 --> 00:10:55,000
So what does object tracking do is object tracking.

221
00:10:55,000 --> 00:10:58,000
Just assign a unique ID each of the detected object.

222
00:10:58,000 --> 00:10:59,000
Just object tracking.

223
00:10:59,000 --> 00:11:02,000
Just sign the unique ID to each other detected object.

224
00:11:02,000 --> 00:11:06,000
Thus, we can also draw the trails as with the help of unique IDs as well.

225
00:11:07,000 --> 00:11:07,000
Okay.

226
00:11:07,000 --> 00:11:09,000
Like the trails which I have shown you.

227
00:11:09,000 --> 00:11:10,000
Like.

228
00:11:10,000 --> 00:11:10,000
Let me show you again.

229
00:11:10,000 --> 00:11:12,000
These are the trails of the vehicles.

230
00:11:12,000 --> 00:11:14,000
Like remove.

231
00:11:15,000 --> 00:11:20,000
Just moving it to show you in a better way so you can see this brown line over here.

232
00:11:22,000 --> 00:11:23,000
You can see this brown line over here.

233
00:11:23,000 --> 00:11:25,000
So these are the trails.

234
00:11:25,000 --> 00:11:26,000
These brown line is basically the trail.

235
00:11:27,000 --> 00:11:27,000
Okay.

236
00:11:28,000 --> 00:11:29,000
Okay.

237
00:11:29,000 --> 00:11:31,000
So I'm just.

238
00:11:31,000 --> 00:11:31,000
Okay.

239
00:11:31,000 --> 00:11:35,000
So basically I have run the upload unzip.

240
00:11:35,000 --> 00:11:37,000
I'm just unzipping the deepsort.

241
00:11:37,000 --> 00:11:39,000
So I have unzip the deepsort files over here.

242
00:11:39,000 --> 00:11:40,000
You can see that.

243
00:11:40,000 --> 00:11:42,000
So now if I just check it.

244
00:11:43,000 --> 00:11:48,000
So we have the unzip folder of Deepsort over here which contains the files for the object tracking as

245
00:11:48,000 --> 00:11:49,000
well.

246
00:11:49,000 --> 00:11:55,000
Okay, now, now we have downloaded a sample video from test for testing our script printed.py file

247
00:11:56,000 --> 00:12:01,000
on from Google Drive and you can see the name of our testing video is test video dot mp4, which is

248
00:12:01,000 --> 00:12:03,000
this video you can see here.

249
00:12:03,000 --> 00:12:06,000
This is the video which I have downloaded from the Google Drive.

250
00:12:06,000 --> 00:12:07,000
Okay.

251
00:12:09,000 --> 00:12:15,000
For the demo video which have shown you I have just downloaded that demo video from Google Drive.

252
00:12:15,000 --> 00:12:19,000
And so basically this is the output demo video which you will get after you run the script.

253
00:12:19,000 --> 00:12:24,000
So you can test this script on some other demo videos as well.

254
00:12:24,000 --> 00:12:25,000
So it's all upon your choice.

255
00:12:25,000 --> 00:12:31,000
But I have tested on this demo video, so I have shown the results for this demo video, so I'm just

256
00:12:31,000 --> 00:12:38,000
downloading the same demo video by the name test video dot mp4 from the Google Drive and here I'm just

257
00:12:38,000 --> 00:12:44,000
downloading the predict.py script updated predict.py script means basically this contains the script

258
00:12:44,000 --> 00:12:50,000
which has been adjusted for this project, which is the detect direction and count vehicles in each

259
00:12:50,000 --> 00:12:51,000
of the direction.

260
00:12:51,000 --> 00:12:52,000
Okay.

261
00:12:52,000 --> 00:12:58,000
So let me open the predict.py predict.py script and let me explain you the complete process flow in

262
00:12:58,000 --> 00:13:00,000
the script as well.

263
00:13:00,000 --> 00:13:00,000
Okay.

264
00:13:00,000 --> 00:13:04,000
So here you can see the predict.py file which I have opened over here.

265
00:13:04,000 --> 00:13:11,000
So I have already added commands before each line you can say before each line of the code so that it

266
00:13:11,000 --> 00:13:14,000
will help you to better understand the code all the way.

267
00:13:15,000 --> 00:13:15,000
Okay.

268
00:13:15,000 --> 00:13:18,000
So let me explain the predict.py script as well.

269
00:13:19,000 --> 00:13:23,000
So first of all, in the meanwhile, let me run the predict.py.

270
00:13:23,000 --> 00:13:30,000
So as we run it so after we explained with the complete script, so in the meanwhile the code would

271
00:13:30,000 --> 00:13:30,000
have been run.

272
00:13:30,000 --> 00:13:34,000
So just running the predict.py file over here.

273
00:13:34,000 --> 00:13:38,000
So it might take few seconds for it to execute.

274
00:13:38,000 --> 00:13:45,000
Like you can see that the predict.py file have just executed with the predict.py file on this test video

275
00:13:45,000 --> 00:13:46,000
which I have downloaded.

276
00:13:46,000 --> 00:13:50,000
And here I'm using the yolo v8 x dot model v8.

277
00:13:50,000 --> 00:13:53,000
Is that the just basically YOLO?

278
00:13:53,000 --> 00:14:00,000
V8 has 5 or 6 different models, five different models and YOLO v8 X is the more most accurate, but

279
00:14:00,000 --> 00:14:08,000
it has a less it is less fast or it is not as much fast than other YOLO V8 model like YOLO V8 and is

280
00:14:08,000 --> 00:14:14,000
less accurate, but it is more fastest and YOLO text is more accurate, but it is less fast.

281
00:14:14,000 --> 00:14:15,000
Or you can say it.

282
00:14:15,000 --> 00:14:19,000
It takes a bit more time than other V8 models.

283
00:14:19,000 --> 00:14:25,000
Okay, so here I am just importing all the required libraries, import hydra and then we have the import

284
00:14:25,000 --> 00:14:26,000
torch library.

285
00:14:26,000 --> 00:14:27,000
So.

286
00:14:28,000 --> 00:14:33,000
As you all know, it is being built using PyTorch to perform object detection tracking using YOLO V8.

287
00:14:34,000 --> 00:14:36,000
So we need to import the PyTorch module.

288
00:14:36,000 --> 00:14:43,000
So to use the PyTorch library, we do import dots because it is being built using pytorch.

289
00:14:43,000 --> 00:14:46,000
So to perform object detection and tracking using YOLO V8.

290
00:14:46,000 --> 00:14:52,000
We need to have the PI torch module and to use PyTorch library we do import torch.

291
00:14:52,000 --> 00:14:52,000
Okay.

292
00:14:52,000 --> 00:14:58,000
So if you want to check the version of the PyTorch library, you can simply print torch dot dash dash

293
00:14:58,000 --> 00:14:59,000
version.

294
00:14:59,000 --> 00:15:02,000
So it will give you the version of the PI torch library.

295
00:15:02,000 --> 00:15:02,000
Okay.

296
00:15:02,000 --> 00:15:10,000
So for the ARGPARSE, basically it helps if you it is basically helps in run basically its command line

297
00:15:10,000 --> 00:15:16,000
parsing library import is basically command line parsing library like you if you pass any arguments

298
00:15:16,000 --> 00:15:17,000
in the command line.

299
00:15:17,000 --> 00:15:25,000
Okay so here imported time if you want to calculate the so you can use this library import time, then

300
00:15:25,000 --> 00:15:26,000
we have the import cv2.

301
00:15:26,000 --> 00:15:33,000
So to implement object texture and then tracking, we use OpenCV Python library, which is Cv2 and two

302
00:15:33,000 --> 00:15:36,000
then we have import torch dot backends dot double.

303
00:15:37,000 --> 00:15:43,000
So torch dot backends basically control the behavior of various backends that PyTorch support.

304
00:15:44,000 --> 00:15:47,000
Then we are importing from numpy import random.

305
00:15:47,000 --> 00:15:51,000
So basically it assigns a random color to each of the detected object.

306
00:15:51,000 --> 00:15:53,000
What I mean by the random color.

307
00:15:53,000 --> 00:15:55,000
So let me show you if I open this.

308
00:15:55,000 --> 00:16:01,000
So now you can see that the card is being assigned a pink color over here and the truck is being assigned

309
00:16:01,000 --> 00:16:02,000
a brown color over here.

310
00:16:02,000 --> 00:16:03,000
Okay.

311
00:16:03,000 --> 00:16:09,000
So basically we get an object detection model randomly assign a color to each other.

312
00:16:09,000 --> 00:16:10,000
Detected object.

313
00:16:11,000 --> 00:16:17,000
Okay, so here I'm just importing from numpy, import random to randomly assign a color to each of the

314
00:16:17,000 --> 00:16:18,000
detected object.

315
00:16:18,000 --> 00:16:18,000
Okay.

316
00:16:18,000 --> 00:16:25,000
So here I'm importing the YOLO required modules from a different file libraries or files from it.

317
00:16:25,000 --> 00:16:28,000
And here I'm just importing the deepsort module.

318
00:16:28,000 --> 00:16:31,000
Basically we are using deepsort to implement object tracking.

319
00:16:33,000 --> 00:16:36,000
So here I'm just importing from collection library.

320
00:16:36,000 --> 00:16:38,000
So DK is basically a list.

321
00:16:38,000 --> 00:16:44,000
So why we can't use simply list over here because queue is preferred over list in the cases where we

322
00:16:44,000 --> 00:16:49,000
need quicker append and pop operation from both ends of the container.

323
00:16:49,000 --> 00:16:52,000
So why we need library over here is let me explain you.

324
00:16:52,000 --> 00:16:58,000
For example, if you see this image, you can see that this object is assigned a unique ID of 59, and

325
00:16:58,000 --> 00:17:01,000
this object has a unique ID of 36.

326
00:17:01,000 --> 00:17:01,000
Okay.

327
00:17:01,000 --> 00:17:03,000
So if the object leaves the frame.

328
00:17:03,000 --> 00:17:09,000
So, for example, when this jet leaves this frame, so we need to remove this ID from our list.

329
00:17:09,000 --> 00:17:10,000
Okay.

330
00:17:10,000 --> 00:17:15,000
And if a new object enters the frame, for example, car enters into the frame.

331
00:17:15,000 --> 00:17:19,000
So we need to add this ID, this unique ID into our list.

332
00:17:19,000 --> 00:17:19,000
Okay.

333
00:17:19,000 --> 00:17:24,000
So when an object leaves the frame, we need to remove the object unique ID from the list.

334
00:17:24,000 --> 00:17:30,000
And when a new object enters the frame, we need to add the unique ID so when object leaves, we need

335
00:17:30,000 --> 00:17:31,000
to remove that unique ID.

336
00:17:31,000 --> 00:17:34,000
When object enters, we need to add that unique ID.

337
00:17:34,000 --> 00:17:38,000
So to do this we use DK library.

338
00:17:38,000 --> 00:17:44,000
So here you can see as DK is preferred over list in the cases where we need quicker append means if

339
00:17:44,000 --> 00:17:50,000
you want to add a new ID and pop like you want to remove the ID when the object leaves the frame.

340
00:17:50,000 --> 00:17:50,000
Okay.

341
00:17:51,000 --> 00:17:57,000
And here we are importing the numpy library because we use numpy library to convert an array into the

342
00:17:57,000 --> 00:17:58,000
list.

343
00:17:58,000 --> 00:18:03,000
Okay, so here I'm just defining a random color palette so that each of the objective objects can be

344
00:18:03,000 --> 00:18:04,000
assigned a random color.

345
00:18:04,000 --> 00:18:06,000
So find a color palette over here.

346
00:18:07,000 --> 00:18:10,000
Okay, so now here I've just created a dictionary by the name data.

347
00:18:10,000 --> 00:18:18,000
So creating a dictionary by the name data is in data dictionary, which will store bottom center coordinates

348
00:18:18,000 --> 00:18:19,000
of the detected objects.

349
00:18:19,000 --> 00:18:23,000
So in data dictionary, we basically store the Let me show you by this.

350
00:18:23,000 --> 00:18:27,000
We store the bottom center coordinates of the detected object.

351
00:18:27,000 --> 00:18:28,000
So let me just remove this.

352
00:18:30,000 --> 00:18:32,000
But this means this is the bottom center coordinate.

353
00:18:32,000 --> 00:18:38,000
You can see that this is the bottom or this line is the bottom of the center quad.

354
00:18:38,000 --> 00:18:40,000
So this is the bottom center coordinate of.

355
00:18:40,000 --> 00:18:43,000
So in the data dictionary, we've stored this values.

356
00:18:43,000 --> 00:18:44,000
Okay.

357
00:18:44,000 --> 00:18:49,000
In each of the frame, what is this center coordinate value over here like the center coordinate value

358
00:18:49,000 --> 00:18:51,000
in the bottom of the bounding box.

359
00:18:51,000 --> 00:18:53,000
Like you can see that this is the bounding box.

360
00:18:53,000 --> 00:18:58,000
And over here and this is the center coordinate at the bottom of the bounding box.

361
00:18:58,000 --> 00:18:58,000
Okay?

362
00:18:58,000 --> 00:19:03,000
So in each of the frame, we store this center, coordinate value, and using this center coordinates

363
00:19:03,000 --> 00:19:04,000
value.

364
00:19:04,000 --> 00:19:05,000
We draw this trails.

365
00:19:05,000 --> 00:19:06,000
Okay, These trails.

366
00:19:06,000 --> 00:19:09,000
Tell us what the vehicle is, what falling, what the path like.

367
00:19:09,000 --> 00:19:11,000
You can see that from this trails.

368
00:19:11,000 --> 00:19:13,000
I can tell this this vehicle has made a turn.

369
00:19:14,000 --> 00:19:14,000
Okay.

370
00:19:14,000 --> 00:19:21,000
So we will just store this bounding box bottom, coordinate like this is the bottom of the bounding

371
00:19:21,000 --> 00:19:24,000
box, the box center value center coordinate value.

372
00:19:24,000 --> 00:19:24,000
Okay.

373
00:19:24,000 --> 00:19:28,000
So we store this center, coordinate value of at the bottom of the bounding box.

374
00:19:28,000 --> 00:19:29,000
Okay.

375
00:19:29,000 --> 00:19:30,000
So.

376
00:19:31,000 --> 00:19:37,000
In the Dayton Visual Dictionary, we store the center coordinate value of the bonding of the D box of

377
00:19:37,000 --> 00:19:43,000
each object in a center, coordinate value at each frame of each of the object we store in this data

378
00:19:43,000 --> 00:19:44,000
dictionary.

379
00:19:44,000 --> 00:19:50,000
Okay, so here we are, initializing the deepsort variable that will be used for that tracking purpose.

380
00:19:50,000 --> 00:19:52,000
Basically we use Deepsort for that tracking.

381
00:19:52,000 --> 00:19:58,000
So now here I'm just creating four dictionaries by the name object counter object counter one object,

382
00:19:58,000 --> 00:20:00,000
counter two and object counter three.

383
00:20:00,000 --> 00:20:06,000
So as in this project, we are counting the traffic going in each of the direction north, south, east

384
00:20:06,000 --> 00:20:07,000
and west.

385
00:20:07,000 --> 00:20:12,000
So first of all here, here we are creating four dictionaries by the name object, counter object,

386
00:20:12,000 --> 00:20:14,000
counter one object, counter two object, counter three.

387
00:20:14,000 --> 00:20:20,000
So as in this project, we are going counting the traffic going in each of the direction north, south,

388
00:20:20,000 --> 00:20:21,000
east and west.

389
00:20:21,000 --> 00:20:27,000
So basically we will count the number of cars, number of trucks, number of buses going in of each

390
00:20:27,000 --> 00:20:28,000
of the direction.

391
00:20:28,000 --> 00:20:34,000
So basically, as you can see, this output demo video, we are just calculating the number of vehicles

392
00:20:34,000 --> 00:20:39,000
going in each of the direction like north, south, east and west, for example.

393
00:20:39,000 --> 00:20:44,000
So I have created four dictionaries for each of the direction, like each direction I have one dictionary

394
00:20:44,000 --> 00:20:48,000
for West Direction, I have one dictionary for North Direction, I have one dictionary.

395
00:20:48,000 --> 00:20:50,000
And for South Direction I've also have one dictionary.

396
00:20:50,000 --> 00:20:51,000
Okay.

397
00:20:51,000 --> 00:20:57,000
So basically the number of trucks, the number of cars going in each of direction, for example, in

398
00:20:57,000 --> 00:21:03,000
or in East Direction dictionary, I have the record number of cars, number of trucks which have gone

399
00:21:03,000 --> 00:21:05,000
gone in the east direction.

400
00:21:05,000 --> 00:21:10,000
So the number of cars, number of trucks which have gone in the east direction will be stored in the

401
00:21:10,000 --> 00:21:11,000
East Direction Dictionary.

402
00:21:12,000 --> 00:21:16,000
Like this is the object counter to represent the dictionary is object.

403
00:21:16,000 --> 00:21:20,000
Counter two is a dictionary empty dictionary for the east direction.

404
00:21:20,000 --> 00:21:20,000
Okay.

405
00:21:20,000 --> 00:21:25,000
So now in the east direction we can see that two cars and three trucks have passed.

406
00:21:25,000 --> 00:21:28,000
So object counter to dictionary will have the record.

407
00:21:28,000 --> 00:21:32,000
Like in the east direction, two cars and three trucks have passed.

408
00:21:32,000 --> 00:21:37,000
So in the west direction object counter three dictionary will have that record like number of trucks,

409
00:21:37,000 --> 00:21:39,000
number of cars have passed in the west direction.

410
00:21:39,000 --> 00:21:40,000
Okay.

411
00:21:40,000 --> 00:21:44,000
So now here we are creating four lines, one line for the each direction.

412
00:21:44,000 --> 00:21:48,000
So here you can see that we have four lines over here.

413
00:21:48,000 --> 00:21:52,000
One, two, three, four, four green lines like this is the first green line.

414
00:21:52,000 --> 00:21:54,000
This is the second green line.

415
00:21:54,000 --> 00:21:55,000
This is the third green line.

416
00:21:55,000 --> 00:21:56,000
This is the fourth green line.

417
00:21:56,000 --> 00:22:02,000
So we are creating four lines, one line for each direction, north, south, east and one west.

418
00:22:02,000 --> 00:22:06,000
When the vehicles trains intersect with this line, then there is an increment.

419
00:22:07,000 --> 00:22:09,000
For example, what I'm saying is.

420
00:22:10,000 --> 00:22:13,000
When this wiggle like these are trails of the vehicle.

421
00:22:13,000 --> 00:22:14,000
I have explained this below.

422
00:22:14,000 --> 00:22:19,000
When these trails of the vehicle intersect with this line, then we can see that increment, like the

423
00:22:19,000 --> 00:22:23,000
vehicle is moving in the north direction or south direction or east or west direction.

424
00:22:23,000 --> 00:22:29,000
I've already explained this thing, so here I'm just initialize the x one, y one coordinate and X2Y

425
00:22:30,000 --> 00:22:31,000
coordinate for each of the line.

426
00:22:31,000 --> 00:22:32,000
So let me explain this.

427
00:22:34,000 --> 00:22:37,000
These workers over here, please focus at this point.

428
00:22:37,000 --> 00:22:38,000
So when I go to here.

429
00:22:38,000 --> 00:22:44,000
So now you can see that at that point we have 622 728 This is the x1y1 value.

430
00:22:44,000 --> 00:22:49,000
And when I go to this line, I have 1533 and 859.

431
00:22:49,000 --> 00:22:51,000
This is the x2 y2 values.

432
00:22:51,000 --> 00:22:51,000
Okay.

433
00:22:51,000 --> 00:22:57,000
So you can see that this is the x1 y1 value and this is the x2 y2 value.

434
00:22:57,000 --> 00:22:58,000
Okay.

435
00:22:58,000 --> 00:23:02,000
So the starting coordinate of the line and the ending coordinate of the line values over here.

436
00:23:03,000 --> 00:23:05,000
So here we are initializing a Deepsort object tracker.

437
00:23:06,000 --> 00:23:09,000
So now here we have the function by the name x, y x y to x y.

438
00:23:10,000 --> 00:23:16,000
So in the define x, y, x, y to x y function we are the converting the bounding box output received

439
00:23:16,000 --> 00:23:20,000
from YOLO V8 to a format that is compatible with deepsort.

440
00:23:20,000 --> 00:23:26,000
So using this function, basically we are converting the bounding box output received by YOLO V8 to

441
00:23:26,000 --> 00:23:29,000
a format that object tracker can also handle.

442
00:23:29,000 --> 00:23:34,000
Okay, so using this function we convert our x and y coordinates to center coordinates which is x,

443
00:23:35,000 --> 00:23:38,000
y, z along with the return the width and height of the bounding box.

444
00:23:38,000 --> 00:23:38,000
Okay.

445
00:23:39,000 --> 00:23:47,000
So in so basically we convert the bounding box coordinates of the YOLO V8 to a format that basically

446
00:23:47,000 --> 00:23:49,000
is compatible with object tracking.

447
00:23:49,000 --> 00:23:50,000
Deepsort object tracking.

448
00:23:50,000 --> 00:23:57,000
So in this output we get the center coordinates of the X, y, z and width and height.

449
00:23:57,000 --> 00:24:00,000
So basically, let me tell you what, at the end of this function we get.

450
00:24:00,000 --> 00:24:06,000
So this function basically returns the center, coordinate like this, coordinate X and y, Z, basically,

451
00:24:06,000 --> 00:24:07,000
if you.

452
00:24:07,000 --> 00:24:11,000
So let's just imagine that this is the center of the boxing box bounding box.

453
00:24:11,000 --> 00:24:14,000
So this function will return the center, coordinate X, y, z.

454
00:24:15,000 --> 00:24:17,000
And the way I see this is.

455
00:24:17,000 --> 00:24:17,000
See.

456
00:24:19,000 --> 00:24:20,000
And the bit.

457
00:24:20,000 --> 00:24:21,000
This is the bit.

458
00:24:22,000 --> 00:24:23,000
And this is the height.

459
00:24:23,000 --> 00:24:29,000
So this function returns that for each of the detected object, we get the center coordinate X, y,

460
00:24:29,000 --> 00:24:33,000
Z, where this is the weight and this is the height of the bounding box.

461
00:24:33,000 --> 00:24:37,000
So in return, we get these four values, okay, for each of the detected object.

462
00:24:37,000 --> 00:24:44,000
So here we convert the X, y, or Z coordinates of the V8 into another format.

463
00:24:44,000 --> 00:24:50,000
But this case we are looking for a but in this case we are only focusing on this x, y, two x, y.

464
00:24:50,000 --> 00:24:53,000
But this function will not be used in this project currently.

465
00:24:53,000 --> 00:24:54,000
Okay.

466
00:24:54,000 --> 00:24:57,000
So now here we are just computing color for each of the label.

467
00:24:57,000 --> 00:25:03,000
For example, we say that if the if the person is detected, then the color of the bounding box will

468
00:25:03,000 --> 00:25:03,000
be this.

469
00:25:03,000 --> 00:25:06,000
If the car is detected, then the color of the bounding box will be this.

470
00:25:06,000 --> 00:25:12,000
So basically I'm saying that if we have detected a car like this, then this color of the bounding box

471
00:25:12,000 --> 00:25:13,000
will be pinned pink.

472
00:25:13,000 --> 00:25:16,000
Okay, So this color of the bounding box will be pink.

473
00:25:16,000 --> 00:25:20,000
So here I've just defined the format of the pink color.

474
00:25:20,000 --> 00:25:20,000
Okay.

475
00:25:20,000 --> 00:25:22,000
Which bounding box color?

476
00:25:22,000 --> 00:25:22,000
Okay.

477
00:25:23,000 --> 00:25:25,000
So basically this is the bounding box color.

478
00:25:25,000 --> 00:25:29,000
I've defined the format of this bounding box color.

479
00:25:30,000 --> 00:25:30,000
Okay.

480
00:25:30,000 --> 00:25:31,000
Over here.

481
00:25:31,000 --> 00:25:37,000
Plus, we say that if the object if, if, if we don't have person car, motorbike and box, for example,

482
00:25:37,000 --> 00:25:39,000
truck appears, for example.

483
00:25:39,000 --> 00:25:42,000
Now, we have not defined the color of the bounding box of the truck.

484
00:25:42,000 --> 00:25:49,000
So if the truck appeared like over here, okay, so that truck color will be assigned randomly using

485
00:25:49,000 --> 00:25:51,000
this color palette which we have created above.

486
00:25:51,000 --> 00:25:51,000
Okay.

487
00:25:52,000 --> 00:25:55,000
So now here we are defining the draw dash border function.

488
00:25:55,000 --> 00:26:00,000
So draw dash border function, create a bounding rectangle over the bounding box where put the text.

489
00:26:00,000 --> 00:26:04,000
So using this draw dash border function, we create this rounded rectangle.

490
00:26:04,000 --> 00:26:08,000
You can see that this rounded rectangle, this rounded rectangle can you see this?

491
00:26:08,000 --> 00:26:11,000
This important part with this rounded rectangle.

492
00:26:11,000 --> 00:26:13,000
So this rounded rectangle is being created.

493
00:26:13,000 --> 00:26:19,000
This rounded rectangle as well is this rounded rectangle is being created using the draw dash border

494
00:26:19,000 --> 00:26:20,000
function.

495
00:26:21,000 --> 00:26:27,000
So when you dash box function, we are passing the cv2 dot rectangle to create a rectangle around the

496
00:26:27,000 --> 00:26:28,000
detected object.

497
00:26:28,000 --> 00:26:32,000
Plus we also obviously are using cv2 dot text to add labels.

498
00:26:32,000 --> 00:26:39,000
So basically, uh, using this dash box function, this one function UI dash box function.

499
00:26:40,000 --> 00:26:44,000
We are creating this rectangle like the square rectangle, this bounding box.

500
00:26:44,000 --> 00:26:47,000
Plus we are also putting text into this.

501
00:26:48,000 --> 00:26:52,000
Roundedrectangle which we have created using the draw dash border function.

502
00:26:52,000 --> 00:26:59,000
So using this draw dash box function, we create this bounding box like this bounding box over here.

503
00:26:59,000 --> 00:27:05,000
Plus we also put the text in this rounded rectangle which we have created using the draw dash border

504
00:27:05,000 --> 00:27:07,000
function, which is above over here.

505
00:27:09,000 --> 00:27:12,000
So now here we have the Intersect and CCW function.

506
00:27:12,000 --> 00:27:17,000
So what this function do is basically here, for example, if we have created two lines.

507
00:27:17,000 --> 00:27:22,000
So now to find whether this lines intersect or not, okay?

508
00:27:22,000 --> 00:27:28,000
So to find whether these two lines intersect or not, two lines intersect or not, this line one and

509
00:27:28,000 --> 00:27:29,000
this line two.

510
00:27:29,000 --> 00:27:32,000
So find whether these two lines intersect or not.

511
00:27:32,000 --> 00:27:36,000
We use these two function, this intersect function over here.

512
00:27:36,000 --> 00:27:37,000
Okay.

513
00:27:37,000 --> 00:27:42,000
So to find whether these two lines which we have intersect or not, we use this intersect function,

514
00:27:42,000 --> 00:27:43,000
which is this.

515
00:27:43,000 --> 00:27:43,000
Okay.

516
00:27:43,000 --> 00:27:46,000
And CCW is being called in this Intersect function.

517
00:27:46,000 --> 00:27:47,000
Okay.

518
00:27:47,000 --> 00:27:49,000
So what we are doing over here.

519
00:27:51,000 --> 00:27:52,000
We basically save.

520
00:27:52,000 --> 00:27:54,000
And this trails intersect with this line.

521
00:27:54,000 --> 00:27:58,000
This green line is when these trails intersect with this line.

522
00:27:58,000 --> 00:28:02,000
Then we can say there is an increment that the truck has passed into the south direction.

523
00:28:02,000 --> 00:28:03,000
Okay.

524
00:28:03,000 --> 00:28:07,000
So basically, we need to find the intersection of these two lines, green line and the trails line

525
00:28:07,000 --> 00:28:08,000
type.

526
00:28:08,000 --> 00:28:16,000
So for this I am creating this Intersect function and to find where our truck is moving in which direction.

527
00:28:16,000 --> 00:28:22,000
So we have created a function by the name get direction so that we can find in which direction our vehicle

528
00:28:22,000 --> 00:28:22,000
is moving.

529
00:28:22,000 --> 00:28:26,000
Either it is moving in the north direction, south direction or west, east or west direction.

530
00:28:26,000 --> 00:28:28,000
Okay, so what are these two points?

531
00:28:28,000 --> 00:28:29,000
0.1 and 0.2.

532
00:28:29,000 --> 00:28:32,000
Basically 0.1 and 0.2 are the.

533
00:28:32,000 --> 00:28:33,000
Let me just explain this over here.

534
00:28:34,000 --> 00:28:34,000
Okay?

535
00:28:34,000 --> 00:28:35,000
Just clean this up.

536
00:28:35,000 --> 00:28:40,000
So basically, 0.1 and 0.2 are this center coordinates value.

537
00:28:40,000 --> 00:28:43,000
This is our first value and this is a second value.

538
00:28:43,000 --> 00:28:46,000
So 0.1 and 0.2 is the center coordinate of the trails value.

539
00:28:46,000 --> 00:28:48,000
These like these are the trails.

540
00:28:48,000 --> 00:28:52,000
So 0.1 and 0.2 are the center coordinate of the trails.

541
00:28:52,000 --> 00:28:53,000
Okay.

542
00:28:53,000 --> 00:28:58,000
Okay, 0.10.2 are the first and second point of the center coordinates of the trails.

543
00:28:58,000 --> 00:28:59,000
Okay, Over here.

544
00:28:59,000 --> 00:28:59,000
These are the trails.

545
00:28:59,000 --> 00:29:00,000
This is the point one.

546
00:29:00,000 --> 00:29:02,000
And this is the 0.2.

547
00:29:03,000 --> 00:29:06,000
So here we are, just calculating the direction of the vehicle.

548
00:29:06,000 --> 00:29:10,000
If there is going the north direction, south direction, east or west direction.

549
00:29:10,000 --> 00:29:13,000
Okay, so here we have just created a draw text box function.

550
00:29:13,000 --> 00:29:18,000
So in draw dash boxes function I am calling as dash box function which I've created above to draw the

551
00:29:18,000 --> 00:29:23,000
bounding box around the detected object and assign unique IDs to each of the detected object.

552
00:29:23,000 --> 00:29:29,000
So in this I told you that why we use object tracking is to assign unique ID to each of the detected

553
00:29:29,000 --> 00:29:35,000
object, which is a function of object tracking to find a unique ID for each of the detected object.

554
00:29:36,000 --> 00:29:41,000
Okay, so here we are, just assigning a unique ID to each other directory object and we are finding

555
00:29:41,000 --> 00:29:43,000
the center of the boundary or bottom edge.

556
00:29:43,000 --> 00:29:49,000
So this is the center of the bottom edge which we am finding like this is the center of the bottom edge

557
00:29:49,000 --> 00:29:51,000
which I am finding over here using this formula.

558
00:29:51,000 --> 00:29:57,000
And here we have the label, the label, we assign an ID and the object name, which you can see that

559
00:29:57,000 --> 00:29:57,000
in label.

560
00:29:57,000 --> 00:30:00,000
We have this ID and the object name over here.

561
00:30:02,000 --> 00:30:07,000
Okay, so here we are just doing if there is an intersection calling the intersection between this,

562
00:30:08,000 --> 00:30:09,000
let me just explain this.

563
00:30:09,000 --> 00:30:16,000
So I'm just I'm saying over here is that you can see that if there is an intersection between this brown

564
00:30:16,000 --> 00:30:19,000
line, you can see over here and this green line, let me show you.

565
00:30:19,000 --> 00:30:20,000
Okay.

566
00:30:20,000 --> 00:30:25,000
So you can see that when this brown line, this brown line intersect with this line, then we can see

567
00:30:25,000 --> 00:30:27,000
an increment like truck goes in the south direction.

568
00:30:27,000 --> 00:30:31,000
So here we are just finding the intersection, just calling the Intersect function, which we have created

569
00:30:31,000 --> 00:30:32,000
above.

570
00:30:32,000 --> 00:30:35,000
And when you see that we have called Cv2 dot line.

571
00:30:35,000 --> 00:30:40,000
So what does it means that when there is an intersection like you can see that.

572
00:30:40,000 --> 00:30:44,000
That when there is a intersection like you can set this brown line.

573
00:30:44,000 --> 00:30:47,000
Intersect with this green line, the green line turns white.

574
00:30:48,000 --> 00:30:53,000
Like you can see that when this brown line intersect with this green line, the green line turns white.

575
00:30:53,000 --> 00:30:55,000
So here we are just doing this.

576
00:30:55,000 --> 00:30:59,000
So when this brown line intersects with the green line, the green line turns white.

577
00:30:59,000 --> 00:31:03,000
So I am just so this is the format of the white color, which I have written over here.

578
00:31:03,000 --> 00:31:08,000
And we are just saying that if the direction of the vehicle is in south, then we will do an increment

579
00:31:08,000 --> 00:31:09,000
over here.

580
00:31:10,000 --> 00:31:13,000
And here we are just drawing the trails over here as well.

581
00:31:13,000 --> 00:31:19,000
And here I'm just setting the counter like, where should I display the counter?

582
00:31:19,000 --> 00:31:24,000
Like, let me tell you, I'm just setting this like this direction will appear here, not direction

583
00:31:24,000 --> 00:31:25,000
will appear here.

584
00:31:25,000 --> 00:31:27,000
So direction will appear here.

585
00:31:27,000 --> 00:31:29,000
West direction will appear here.

586
00:31:29,000 --> 00:31:35,000
So here I'm just setting the different elements, like where I need to put the text of the West direction

587
00:31:35,000 --> 00:31:38,000
or other total count and other things as well.

588
00:31:38,000 --> 00:31:44,000
And this is the class detection prediction of the V8 and just calling all this over here.

589
00:31:44,000 --> 00:31:46,000
So this is all from this.

590
00:31:46,000 --> 00:31:47,000
Let me show you the output.

591
00:31:47,000 --> 00:31:51,000
So we have run the script over here, the predict.py file.

592
00:31:51,000 --> 00:31:52,000
Okay.

593
00:31:52,000 --> 00:31:55,000
So here we also have this output demo video.

594
00:31:55,000 --> 00:31:56,000
So if I just download it.

595
00:31:57,000 --> 00:31:57,000
Okay.

596
00:31:57,000 --> 00:31:59,000
So it might be let me just download it.

597
00:31:59,000 --> 00:32:00,000
Okay.

598
00:32:00,000 --> 00:32:06,000
So I've just downloaded this output video so you can see that as it goes through goes in the north direction.

599
00:32:06,000 --> 00:32:06,000
We have increment.

600
00:32:06,000 --> 00:32:11,000
The truck has gone to the north direction and as this vehicle goes into east direction, we have an

601
00:32:11,000 --> 00:32:17,000
incorrect one car has gone to the east direction and when this goes to the east direction we have increment

602
00:32:17,000 --> 00:32:20,000
like car has also gone to the east direction.

603
00:32:20,000 --> 00:32:21,000
We can see the increment over here.

604
00:32:21,000 --> 00:32:24,000
So in this way all this process works.

605
00:32:24,000 --> 00:32:30,000
I hope you have learned a lot from this video tutorial and see you all in the next video tutorial.

606
00:32:30,000 --> 00:32:31,000
Till then, bye bye.

607
00:32:31,000 --> 00:32:32,000
Have a very good day.

