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 see how we can implement vehicle counting using YOLO V8 and Deepsort

3
00:00:10,000 --> 00:00:11,000
object tracking.

4
00:00:11,000 --> 00:00:15,000
So this is the output we get when we run YOLO.

5
00:00:15,000 --> 00:00:22,000
When we integrate object tracking using Deepsort with YOLO V8, which we have done in the previous lectures.

6
00:00:22,000 --> 00:00:23,000
So let me show you the output.

7
00:00:23,000 --> 00:00:29,000
So this is the output we get when we integrate YOLO object tracking with YOLO V8.

8
00:00:29,000 --> 00:00:35,000
So you can see that we have truck over here, we have cars over here.

9
00:00:35,000 --> 00:00:38,000
Okay, so now we need to count the vehicles.

10
00:00:38,000 --> 00:00:43,000
Currently you can see that we are getting a unique ID with each of the object and the trails as well.

11
00:00:43,000 --> 00:00:44,000
Okay.

12
00:00:44,000 --> 00:00:48,000
But in this lecture, our goal is to count each of the vehicle.

13
00:00:48,000 --> 00:00:51,000
For example, one, two, three, four, five, six, seven, eight.

14
00:00:51,000 --> 00:00:57,000
So I need to count the number of vehicles passing this line and the number of vehicles going over here

15
00:00:57,000 --> 00:00:57,000
as well.

16
00:00:57,000 --> 00:01:03,000
So I need to count the total number of vehicles which passed this line in the video.

17
00:01:03,000 --> 00:01:03,000
Okay.

18
00:01:03,000 --> 00:01:11,000
So to count the number of vehicles in a video or if you want to count any object in a video, so how

19
00:01:11,000 --> 00:01:12,000
you can do this.

20
00:01:12,000 --> 00:01:16,000
So first of all, let me save a photo from this video.

21
00:01:16,000 --> 00:01:20,000
Then I will try to explain you the concept that how we will do this.

22
00:01:21,000 --> 00:01:24,000
So it will save a photo from the video.

23
00:01:24,000 --> 00:01:26,000
So, okay, click on Save a Photo.

24
00:01:28,000 --> 00:01:32,000
And then it will just in test three, dash one.

25
00:01:32,000 --> 00:01:34,000
So now we'll go to the pictures folder.

26
00:01:35,000 --> 00:01:36,000
Okay.

27
00:01:36,000 --> 00:01:37,000
So.

28
00:01:38,000 --> 00:01:42,000
Let's go to the pictures folder and it's about test three moment.

29
00:01:43,000 --> 00:01:46,000
And let me open paint or open with.

30
00:01:47,000 --> 00:01:49,000
And so let us open with paint.

31
00:01:49,000 --> 00:01:50,000
Okay.

32
00:01:50,000 --> 00:01:51,000
So basically.

33
00:01:52,000 --> 00:01:55,000
And if we want to count the number of vehicles in this scenario.

34
00:01:55,000 --> 00:02:01,000
So first I will what I will do first of all, I will just create a line over here.

35
00:02:02,000 --> 00:02:08,000
You can see that I will just create a line over here and I will say that whenever the vehicle crosses

36
00:02:08,000 --> 00:02:12,000
this line, so whenever any vehicle crosses this line from here.

37
00:02:13,000 --> 00:02:19,000
And from here as well on both of the sides, when the vehicle crosses this line, like vehicles coming

38
00:02:19,000 --> 00:02:24,000
from here and cross this line and the vehicle coming from here, cross this line, I will increment

39
00:02:24,000 --> 00:02:27,000
the count like car number of cars.

40
00:02:27,000 --> 00:02:29,000
For example, Three cars have passed.

41
00:02:29,000 --> 00:02:34,000
Four have passed have passed this line or and when the truck passes this line, similarly, I will increment

42
00:02:34,000 --> 00:02:35,000
the count like that.

43
00:02:35,000 --> 00:02:37,000
Like that truck has passed.

44
00:02:37,000 --> 00:02:38,000
Five trucks have passed.

45
00:02:38,000 --> 00:02:39,000
Six trucks have passed.

46
00:02:43,000 --> 00:02:50,000
What we will do in this case is like you can see that this is the center of the bottom, but basically

47
00:02:50,000 --> 00:02:53,000
center coordinate of the bottom of the bounding box.

48
00:02:53,000 --> 00:02:54,000
Can you see this over here?

49
00:02:54,000 --> 00:02:58,000
So when this center coordinate like this one.

50
00:02:59,000 --> 00:03:02,000
See the center coordinate of the bottom of the bounding box.

51
00:03:02,000 --> 00:03:03,000
Okay.

52
00:03:03,000 --> 00:03:12,000
So when this center point crosses this line, like this black line is crossed by this center coordinate

53
00:03:12,000 --> 00:03:14,000
of the bottom of the bounding box.

54
00:03:14,000 --> 00:03:17,000
Then we will increment the counter like three cars have passed.

55
00:03:17,000 --> 00:03:19,000
Four cars has passed like.

56
00:03:19,000 --> 00:03:21,000
And the truck, three trucks has passed.

57
00:03:21,000 --> 00:03:22,000
Five trucks have passed.

58
00:03:22,000 --> 00:03:30,000
So when this center coordinate of the bottom of the bounding box crosses this line, then we will increment

59
00:03:30,000 --> 00:03:31,000
the counter like this.

60
00:03:31,000 --> 00:03:32,000
Coordinate crosses this line.

61
00:03:32,000 --> 00:03:33,000
Okay.

62
00:03:33,000 --> 00:03:34,000
So.

63
00:03:35,000 --> 00:03:36,000
For this.

64
00:03:36,000 --> 00:03:40,000
We need to find the intersection between this line and the sorted center coordinate.

65
00:03:40,000 --> 00:03:47,000
So we need to find the intersection between this line, this black line and the center coordinate.

66
00:03:47,000 --> 00:03:47,000
Okay.

67
00:03:47,000 --> 00:03:52,000
So first of all, what we will do is, first of all, I will go to this repo.

68
00:03:52,000 --> 00:03:54,000
Yolo, Deepsort object tracking repo.

69
00:03:54,000 --> 00:03:59,000
And here I have created a folder for this project by the name recounting your tutorial.

70
00:03:59,000 --> 00:04:01,000
So I will open PyCharm.

71
00:04:01,000 --> 00:04:05,000
You can choose any other ID as per your choice.

72
00:04:05,000 --> 00:04:07,000
So I will open PyCharm.

73
00:04:08,000 --> 00:04:09,000
Suck my dick.

74
00:04:09,000 --> 00:04:10,000
Two seconds.

75
00:04:21,000 --> 00:04:21,000
Okay.

76
00:04:21,000 --> 00:04:24,000
So it will it is preparing the working space workspace.

77
00:04:25,000 --> 00:04:27,000
So it is about to ready.

78
00:04:27,000 --> 00:04:27,000
Okay.

79
00:04:27,000 --> 00:04:30,000
So as it gets ready, then we will start.

80
00:04:31,000 --> 00:04:31,000
Okay.

81
00:04:31,000 --> 00:04:33,000
So I will go to file.

82
00:04:35,000 --> 00:04:39,000
I will click one file and create a new project.

83
00:04:40,000 --> 00:04:45,000
A new project and then I will go to here and select the folder first.

84
00:04:46,000 --> 00:04:52,000
So we add course vehicle contain, and here we have the folder which we have created.

85
00:04:53,000 --> 00:04:56,000
Name of the folder is vehicle coding tutorial.

86
00:04:57,000 --> 00:04:59,000
Okay, just refresh it.

87
00:04:59,000 --> 00:05:00,000
Okay.

88
00:05:00,000 --> 00:05:00,000
This is the.

89
00:05:02,000 --> 00:05:04,000
Folder which we have created for this project.

90
00:05:04,000 --> 00:05:05,000
Select this.

91
00:05:05,000 --> 00:05:08,000
And you can see our vehicle continue the tutorial.

92
00:05:08,000 --> 00:05:10,000
We will continue the tutorial.

93
00:05:10,000 --> 00:05:16,000
Then we'll create a new project, select this window, and now the new project is created.

94
00:05:17,000 --> 00:05:18,000
First of all, I will open the terminal.

95
00:05:21,000 --> 00:05:23,000
So just open the terminal over here.

96
00:05:24,000 --> 00:05:26,000
Pockets, creating a virtual environment.

97
00:05:26,000 --> 00:05:28,000
So it might take some few seconds more.

98
00:05:28,000 --> 00:05:31,000
Okay, so just open the terminal over here.

99
00:05:33,000 --> 00:05:35,000
And just go to this repo.

100
00:05:36,000 --> 00:05:39,000
And just follow the steps run code.

101
00:05:39,000 --> 00:05:44,000
So just copy this step and just paste this over here and click on Enter.

102
00:05:45,000 --> 00:05:47,000
So in order to clone the repo over here.

103
00:05:48,000 --> 00:05:52,000
It might take two seconds to for the completed report to be blown over here.

104
00:05:53,000 --> 00:05:56,000
So we will wait for a few seconds until it gets completely blown.

105
00:05:58,000 --> 00:05:59,000
It's the 1% in law.

106
00:05:59,000 --> 00:06:04,000
What it will execute much faster shortly, like you can say 67% now.

107
00:06:04,000 --> 00:06:07,000
And now it will go to 85 and then onward 75.

108
00:06:08,000 --> 00:06:12,000
We'll now eat this stool and then it will go to 99 and 100.

109
00:06:14,000 --> 00:06:16,000
For canceling that episode.

110
00:06:16,000 --> 00:06:19,000
Now we need to set the current directory as this current repo.

111
00:06:19,000 --> 00:06:23,000
I have already explained these things in the previous.

112
00:06:24,000 --> 00:06:25,000
Okay.

113
00:06:26,000 --> 00:06:29,000
I think I've doubled this, but I've written this.

114
00:06:31,000 --> 00:06:31,000
Multiple times.

115
00:06:31,000 --> 00:06:36,000
So now I am installing all the dependencies, which are the requirements as well.

116
00:06:36,000 --> 00:06:38,000
So just copy and press enter.

117
00:06:38,000 --> 00:06:41,000
So now all the dependencies will be installed.

118
00:06:42,000 --> 00:06:46,000
So it means dependencies are the required libraries required to run the code.

119
00:06:46,000 --> 00:06:49,000
So this might take few seconds.

120
00:06:50,000 --> 00:06:51,000
So.

121
00:06:53,000 --> 00:06:56,000
As we are going to perform the detection over here.

122
00:06:56,000 --> 00:07:01,000
So I will go to ultralytics, YOLO V8 and select the grand directory as my detection folder.

123
00:07:02,000 --> 00:07:04,000
So just have just copy the command from here.

124
00:07:04,000 --> 00:07:08,000
And now my current directory is set with the detection folder.

125
00:07:08,000 --> 00:07:09,000
Okay.

126
00:07:09,000 --> 00:07:11,000
So now we are downloading that.

127
00:07:11,000 --> 00:07:13,000
We will download the deepsort files from the Google Drive.

128
00:07:13,000 --> 00:07:18,000
You can just copy this link and just download the files from here.

129
00:07:20,000 --> 00:07:24,000
So I have already downloaded this file, so I will just go over here.

130
00:07:25,000 --> 00:07:28,000
Just copy this zip file and just come here.

131
00:07:28,000 --> 00:07:29,000
This is my folder.

132
00:07:29,000 --> 00:07:30,000
Unzip it.

133
00:07:30,000 --> 00:07:30,000
Now.

134
00:07:32,000 --> 00:07:42,000
Okay, so just unzip it now and after unzipping go to here, copy this folder and just go to Radix YOLO

135
00:07:42,000 --> 00:07:48,000
v eight detect and just paste this folder over here.

136
00:07:48,000 --> 00:07:52,000
Okay, so now basically we are implementing object tracking using Deepsort.

137
00:07:52,000 --> 00:07:57,000
So we need to have the Deepsort code integrated with the YOLO V8.

138
00:07:57,000 --> 00:07:58,000
Okay.

139
00:07:58,000 --> 00:08:02,000
Now we will download a demo video from Google Drive.

140
00:08:03,000 --> 00:08:05,000
So basically in which we will test our model.

141
00:08:06,000 --> 00:08:08,000
So, okay.

142
00:08:08,000 --> 00:08:11,000
I think there were mistakenly just copy this.

143
00:08:12,000 --> 00:08:15,000
Angus incident Press Enter now.

144
00:08:15,000 --> 00:08:20,000
No demo video will be downloaded from the Google Drive on which we will test our model.

145
00:08:22,000 --> 00:08:26,000
Next is to basically run the python predict.py model.

146
00:08:27,000 --> 00:08:33,000
So if you run this script it will basically perform the object tracking.

147
00:08:33,000 --> 00:08:33,000
Okay.

148
00:08:33,000 --> 00:08:36,000
But I need to explain the concept of vehicle counting.

149
00:08:36,000 --> 00:08:44,000
So let's me just open the predict.py script and add the vehicle counting code and then we will run this.

150
00:08:44,000 --> 00:08:50,000
Scripts so that we can in the output, we can not only see the object tracking, but also we can see

151
00:08:50,000 --> 00:08:52,000
that a vehicle counting as well.

152
00:08:52,000 --> 00:08:59,000
So the first thing you need to do is basically we need to just go over here basically.

153
00:08:59,000 --> 00:09:01,000
First thing we need to create a line.

154
00:09:01,000 --> 00:09:04,000
So we need to find the coordinates on which we need to create the line.

155
00:09:05,000 --> 00:09:06,000
So.

156
00:09:07,000 --> 00:09:14,000
You can see over here this when just pointer please see this point where my current mouse is.

157
00:09:14,000 --> 00:09:16,000
Please focus on this point.

158
00:09:16,000 --> 00:09:17,000
Okay.

159
00:09:17,000 --> 00:09:21,000
So currently the value at this point is 249 438.

160
00:09:21,000 --> 00:09:22,000
Okay.

161
00:09:23,000 --> 00:09:29,000
Average values to 14 to 54, 41 to 5441.

162
00:09:29,000 --> 00:09:32,000
So now I will just create a line over here.

163
00:09:32,000 --> 00:09:35,000
I will write line is equal to.

164
00:09:36,000 --> 00:09:36,000
Okay.

165
00:09:37,000 --> 00:09:43,000
So the point was, I'm just again forgetting it's 250 to 250 and 441.

166
00:09:44,000 --> 00:09:45,000
Okay.

167
00:09:45,000 --> 00:09:52,000
So it's two 5441 and the next end point is where the line end is.

168
00:09:52,000 --> 00:09:56,000
So the value at this point is 1452.

169
00:09:56,000 --> 00:09:57,000
Okay.

170
00:09:57,000 --> 00:09:59,000
1452.

171
00:09:59,000 --> 00:10:01,000
Just write it here.

172
00:10:01,000 --> 00:10:02,000
1000.

173
00:10:03,000 --> 00:10:04,000
452 over here.

174
00:10:05,000 --> 00:10:10,000
Okay, So this is the line which we need to create when the basically when the.

175
00:10:12,000 --> 00:10:13,000
So this is the line we need to create.

176
00:10:13,000 --> 00:10:16,000
Basically, when this center coordinate intersect this this line.

177
00:10:16,000 --> 00:10:21,000
So we can say that the car has passed and we can we can increment the counter.

178
00:10:21,000 --> 00:10:22,000
Okay.

179
00:10:22,000 --> 00:10:27,000
So first then we need to create a dictionary by the name of counter.

180
00:10:27,000 --> 00:10:29,000
We will store the count.

181
00:10:29,000 --> 00:10:34,000
So object counter is equal to basically empty dictionary currently.

182
00:10:34,000 --> 00:10:39,000
So in this basic in object counter, we will store the total count of each vehicle.

183
00:10:39,000 --> 00:10:40,000
Okay, guys.

184
00:10:40,000 --> 00:10:42,000
So next we will go ahead.

185
00:10:42,000 --> 00:10:51,000
And now what we need to do is basically we need to basically write a function for the intersection.

186
00:10:52,000 --> 00:10:52,000
Okay?

187
00:10:52,000 --> 00:10:58,000
So basically now we need to write the function for the intersection, like when these this center coordinate

188
00:10:58,000 --> 00:11:00,000
intersect with this line.

189
00:11:00,000 --> 00:11:03,000
We need to increment the counter of the vehicle.

190
00:11:03,000 --> 00:11:04,000
So.

191
00:11:05,000 --> 00:11:07,000
You need to write the intersection function over here.

192
00:11:07,000 --> 00:11:10,000
So basically, let me show you one thing.

193
00:11:11,000 --> 00:11:12,000
Just go to here.

194
00:11:12,000 --> 00:11:13,000
I have already worked on it.

195
00:11:13,000 --> 00:11:18,000
So here, just open this with paint and so.

196
00:11:19,000 --> 00:11:21,000
Guys when these two lines intersect.

197
00:11:21,000 --> 00:11:25,000
So to represent in the python code form, we usually have this.

198
00:11:27,000 --> 00:11:28,000
Rewrite this function.

199
00:11:28,000 --> 00:11:32,000
Basically, we are calling CCW inside this Intersect function.

200
00:11:32,000 --> 00:11:33,000
So we require this function.

201
00:11:33,000 --> 00:11:35,000
Okay, so.

202
00:11:36,000 --> 00:11:42,000
And again, I'm telling you basically in Python to write the intersection, to find the intersection

203
00:11:42,000 --> 00:11:48,000
between two points, two lines in Python, to find the intersection between two lines, see line one

204
00:11:48,000 --> 00:11:50,000
and this is line two.

205
00:11:50,000 --> 00:11:53,000
We usually write this python code.

206
00:11:53,000 --> 00:11:59,000
It will returns true if the line segment of line line, segment, AB and CD intersect.

207
00:11:59,000 --> 00:12:02,000
For example, this is like a line segment.

208
00:12:02,000 --> 00:12:04,000
AB and C this is a line segment.

209
00:12:04,000 --> 00:12:08,000
CD So this function returns true if the line segment AB and CD intersect.

210
00:12:08,000 --> 00:12:11,000
Two So I will write this function.

211
00:12:12,000 --> 00:12:13,000
Over here.

212
00:12:17,000 --> 00:12:21,000
Just now write down this mansion and just over here.

213
00:12:21,000 --> 00:12:25,000
So first we will write, define, Intersect.

214
00:12:30,000 --> 00:12:38,000
Eight comma B, comma C, comma d, and just enter the column here and then will return a CCW.

215
00:12:38,000 --> 00:12:42,000
Basically, we will create a function after this.

216
00:12:42,000 --> 00:12:46,000
And here will basically I'm passing all the four points one three by three four.

217
00:12:47,000 --> 00:12:53,000
Okay, So just write a single command over here and then.

218
00:12:53,000 --> 00:12:54,000
Yes.

219
00:12:54,000 --> 00:12:54,000
Right.

220
00:12:54,000 --> 00:12:55,000
This.

221
00:12:56,000 --> 00:13:04,000
C equals C comma D over here and then write a CCW.

222
00:13:04,000 --> 00:13:12,000
Then I will write a comma, B, comma, C over here, and then I will write a CCW.

223
00:13:14,000 --> 00:13:21,000
Then I think about CCW and a comma B, comma.

224
00:13:21,000 --> 00:13:22,000
D over here.

225
00:13:22,000 --> 00:13:28,000
Okay, so we can see I have just spelled A and over here, so it's now fine.

226
00:13:28,000 --> 00:13:36,000
We have a comma, C, comma, D, B, comma, C, comma d, and then we have a, b, c, a b, d.

227
00:13:36,000 --> 00:13:37,000
Okay, that's fine.

228
00:13:37,000 --> 00:13:41,000
So now we need to create this CCW function.

229
00:13:42,000 --> 00:13:51,000
So to create this CCW function, just write to the CCW, a comma, B, comma, C, and just I've just

230
00:13:51,000 --> 00:13:52,000
mistakenly.

231
00:13:52,000 --> 00:13:55,000
And then press enter and return.

232
00:13:56,000 --> 00:14:00,000
Basically, I'm just writing down this function, which I have shown you over here.

233
00:14:00,000 --> 00:14:03,000
I'm just writing down these two functions over here.

234
00:14:03,000 --> 00:14:07,000
Okay, so return C one.

235
00:14:08,000 --> 00:14:09,000
Minus.

236
00:14:15,000 --> 00:14:16,000
Well, I have written this function.

237
00:14:16,000 --> 00:14:21,000
So here we have the Intersect and here is the CCW function.

238
00:14:21,000 --> 00:14:26,000
So now we'll go down and over here.

239
00:14:26,000 --> 00:14:34,000
So, okay, so just now what we need to do is we need to write if then that.

240
00:14:37,000 --> 00:14:37,000
These.

241
00:14:37,000 --> 00:14:37,000
Great.

242
00:14:37,000 --> 00:14:41,000
The minute I will explain to you what I am doing currently over here.

243
00:14:41,000 --> 00:14:44,000
So if you see this image.

244
00:14:45,000 --> 00:14:47,000
So you can see that here.

245
00:14:47,000 --> 00:14:48,000
This is a center coordinate.

246
00:14:49,000 --> 00:14:53,000
Basically, we if you can see this center coordinate length.

247
00:14:53,000 --> 00:14:56,000
So this trail length is Max.

248
00:14:56,000 --> 00:15:00,000
We we have set that that maximum length of trails should be 64.

249
00:15:00,000 --> 00:15:01,000
Okay.

250
00:15:01,000 --> 00:15:04,000
So that these trails, maximum length is 64.

251
00:15:04,000 --> 00:15:11,000
So how these trails are calculated, basically, we append the center, coordinate values into the data

252
00:15:11,000 --> 00:15:18,000
dictionary, like the center, coordinate values of each of the frame of each of the frame are appended

253
00:15:18,000 --> 00:15:20,000
to the data dictionary.

254
00:15:20,000 --> 00:15:25,000
So when these center cabinet lengths increases, this trails length increases.

255
00:15:25,000 --> 00:15:32,000
Okay, so now we are saying that we should at least have two values of the center coordinate in that

256
00:15:32,000 --> 00:15:32,000
dictionary.

257
00:15:32,000 --> 00:15:33,000
Okay.

258
00:15:33,000 --> 00:15:34,000
That is the dictionary.

259
00:15:34,000 --> 00:15:39,000
And it should contain at least two values of the center coordinate.

260
00:15:39,000 --> 00:15:46,000
So when there are at least two values of the center coordinate, then we can then the object can intersect

261
00:15:46,000 --> 00:15:48,000
with the line with this line.

262
00:15:49,000 --> 00:15:53,000
And with this line and then we can have an increment in the counter.

263
00:15:53,000 --> 00:15:56,000
Okay, so just write if intersect.

264
00:15:56,000 --> 00:16:02,000
Now I'm just calling this function over here, and this is a data first value just passing.

265
00:16:03,000 --> 00:16:07,000
And now I'm passing the second value of data over here.

266
00:16:09,000 --> 00:16:11,000
Okay, then I'm passing the.

267
00:16:13,000 --> 00:16:14,000
Then I am over here.

268
00:16:14,000 --> 00:16:20,000
I will post at this point of the line and next I will pass this point of the line.

269
00:16:20,000 --> 00:16:22,000
So just passing the.

270
00:16:23,000 --> 00:16:25,000
X1Y1 point of the line.

271
00:16:28,000 --> 00:16:28,000
Okay.

272
00:16:29,000 --> 00:16:32,000
And now I will pass the other point of the line over here.

273
00:16:33,000 --> 00:16:34,000
Okay, that's good.

274
00:16:34,000 --> 00:16:35,000
So.

275
00:16:36,000 --> 00:16:43,000
What I want to do is so when this when the center coordinates, I want when the center coordinates intersect

276
00:16:43,000 --> 00:16:47,000
with this line, the color of this black line should change to white.

277
00:16:48,000 --> 00:16:51,000
Okay, So for this I will write cv2 dot line.

278
00:16:53,000 --> 00:16:53,000
Image.

279
00:16:54,000 --> 00:16:56,000
And then line zero.

280
00:16:58,000 --> 00:17:05,000
Walden line one just passing these venues and what color we want is.

281
00:17:06,000 --> 00:17:11,000
While sewing the white color is provided as two over five, two over five.

282
00:17:11,000 --> 00:17:15,000
You can check this as well and the line thickness should be three.

283
00:17:15,000 --> 00:17:15,000
Okay.

284
00:17:15,000 --> 00:17:17,000
The next we will do is.

285
00:17:17,000 --> 00:17:23,000
So now we want to we will append each of the detected object into a dictionary.

286
00:17:23,000 --> 00:17:24,000
So when the.

287
00:17:25,000 --> 00:17:27,000
So let me show you again.

288
00:17:27,000 --> 00:17:27,000
So.

289
00:17:29,000 --> 00:17:34,000
So each of the detected object will be appended into this when the.

290
00:17:35,000 --> 00:17:36,000
Let me explain a better way.

291
00:17:36,000 --> 00:17:46,000
So when this object crosses intersect with this line, okay, so the object will be saved in this dictionary,

292
00:17:46,000 --> 00:17:47,000
which is name is object counter.

293
00:17:47,000 --> 00:17:54,000
So when the object of the same name appears again, it will automatically increment like two cars have

294
00:17:54,000 --> 00:17:55,000
passed.

295
00:17:55,000 --> 00:17:56,000
Three cars have passed.

296
00:17:56,000 --> 00:17:58,000
Okay, so just doing this now.

297
00:18:00,000 --> 00:18:02,000
And I am doing this over here.

298
00:18:03,000 --> 00:18:04,000
Okay, So if you check.

299
00:18:06,000 --> 00:18:08,000
Is more in.

300
00:18:09,000 --> 00:18:11,000
Object counter.

301
00:18:12,000 --> 00:18:14,000
Okay, So basically, I'm trying.

302
00:18:17,000 --> 00:18:18,000
Object.

303
00:18:19,000 --> 00:18:20,000
Boundary which we have created here.

304
00:18:21,000 --> 00:18:24,000
Okay, so then we have object name.

305
00:18:26,000 --> 00:18:29,000
Just close this and just click over here.

306
00:18:30,000 --> 00:18:34,000
Then we can say object counter is equal to one.

307
00:18:34,000 --> 00:18:35,000
Then ends.

308
00:18:36,000 --> 00:18:37,000
Object.

309
00:18:39,000 --> 00:18:39,000
Under.

310
00:18:41,000 --> 00:18:43,000
Mass is equal to one.

311
00:18:43,000 --> 00:18:45,000
Okay, So this is fine.

312
00:18:46,000 --> 00:18:53,000
Now we will say that object counter is if the object name is there, not in object counter, we can

313
00:18:53,000 --> 00:18:55,000
say that object counter is equal to one else.

314
00:18:55,000 --> 00:18:57,000
Object counter plus is equal to one.

315
00:19:03,000 --> 00:19:10,000
Now I want to display this count in like, I want to display the count of each of the vicar over here.

316
00:19:10,000 --> 00:19:14,000
Okay, So for this, let's write down the script.

317
00:19:14,000 --> 00:19:16,000
So I will write.

318
00:19:17,000 --> 00:19:18,000
Oh.

319
00:19:20,000 --> 00:19:21,000
ADX.

320
00:19:21,000 --> 00:19:22,000
Let me write down.

321
00:19:28,000 --> 00:19:29,000
So just.

322
00:19:29,000 --> 00:19:36,000
Okay, so I'm here acting for x, comma, comma value.

323
00:19:38,000 --> 00:19:39,000
And a.

324
00:19:43,000 --> 00:19:46,000
Like now we write object counter.

325
00:19:47,000 --> 00:19:47,000
Darn.

326
00:19:47,000 --> 00:19:48,000
I don't.

327
00:19:51,000 --> 00:19:51,000
Okay.

328
00:19:51,000 --> 00:19:54,000
So then I will just check all the all here then.

329
00:19:54,000 --> 00:19:59,000
Kone's frame is equal to.

330
00:19:59,000 --> 00:20:00,000
SGI.

331
00:20:09,000 --> 00:20:12,000
And I'm read this and then I like.

332
00:20:14,000 --> 00:20:18,000
Just to add the underscore doctor as a right here this process.

333
00:20:19,000 --> 00:20:23,000
Then I would write cv2 dot line.

334
00:20:24,000 --> 00:20:27,000
So, Mr. Game, just creating a line right here.

335
00:20:28,000 --> 00:20:30,000
It could be at or a thick line.

336
00:20:31,000 --> 00:20:33,000
We're just setting the coordinates.

337
00:20:34,000 --> 00:20:40,000
Hold the line where the total width -150 distinguished in the top right corner.

338
00:20:41,000 --> 00:20:42,000
What, five?

339
00:20:47,000 --> 00:20:48,000
Idexx.

340
00:20:50,000 --> 00:20:51,000
40.

341
00:20:51,000 --> 00:20:54,000
Then I will ride their spine completely.

342
00:20:54,000 --> 00:20:56,000
Then what I will do is.

343
00:20:56,000 --> 00:20:56,000
Okay.

344
00:20:56,000 --> 00:20:57,000
That's okay.

345
00:20:57,000 --> 00:20:59,000
Now we have defined the width as well.

346
00:21:00,000 --> 00:21:02,000
And in the next step I will define.

347
00:21:03,000 --> 00:21:05,000
Where this line will end.

348
00:21:05,000 --> 00:21:08,000
The end point of this line is point 25.

349
00:21:09,000 --> 00:21:10,000
Last.

350
00:21:12,000 --> 00:21:12,000
It.

351
00:21:14,000 --> 00:21:16,000
X was 40.

352
00:21:17,000 --> 00:21:20,000
And then I have now defined the endpoint of this line.

353
00:21:20,000 --> 00:21:20,000
Okay.

354
00:21:21,000 --> 00:21:26,000
So now the color of line we need to define over here, which is 85.

355
00:21:26,000 --> 00:21:27,000
45.

356
00:21:27,000 --> 00:21:29,000
You can choose any color of the line.

357
00:21:29,000 --> 00:21:35,000
I'm just randomly assigning this color and the line thickness should be 30, should be a very big line.

358
00:21:35,000 --> 00:21:44,000
Then I will write cv2 dot, put text over here and then I will write image count string and then I will

359
00:21:44,000 --> 00:21:45,000
write this.

360
00:21:46,000 --> 00:21:49,000
Now I'm just adjusting my text into on this line where.

361
00:21:51,000 --> 00:21:52,000
-150.

362
00:21:54,000 --> 00:21:56,000
Rate -150.

363
00:21:57,000 --> 00:21:58,000
My 35.

364
00:22:00,000 --> 00:22:01,000
35 miles.

365
00:22:03,000 --> 00:22:05,000
80 Cross 40.

366
00:22:07,000 --> 00:22:09,000
And let's finish this over here.

367
00:22:09,000 --> 00:22:12,000
Then I will write zero comma one.

368
00:22:12,000 --> 00:22:18,000
And then I will write the color of the text and it should be like white color.

369
00:22:18,000 --> 00:22:22,000
And the thickness of the text should be two.

370
00:22:22,000 --> 00:22:29,000
And for the line type, I'm just adjusting line type is equal to.

371
00:22:33,000 --> 00:22:35,000
Cv2 dot zero.

372
00:22:36,000 --> 00:22:38,000
Notice here we don't have the option line.

373
00:22:38,000 --> 00:22:43,000
Okay, so I have done this from my side completely.

374
00:22:43,000 --> 00:22:46,000
Let us run this script and see if there are any errors.

375
00:22:46,000 --> 00:22:49,000
Then we can correct it shortly.

376
00:22:49,000 --> 00:22:50,000
Okay.

377
00:22:50,000 --> 00:22:53,000
Just giving a look towards the test once.

378
00:22:53,000 --> 00:22:55,000
So now we will just run this script.

379
00:22:56,000 --> 00:22:58,000
So let's go over here.

380
00:22:58,000 --> 00:22:59,000
This goes in this.

381
00:23:00,000 --> 00:23:05,000
And just copy this and just place it and press enter.

382
00:23:06,000 --> 00:23:08,000
So we want to show the output that the runtime.

383
00:23:08,000 --> 00:23:10,000
So let's see what it goes.

384
00:23:12,000 --> 00:23:14,000
So it might take some time to execute.

385
00:23:14,000 --> 00:23:17,000
If there is no error in case of error, it will generate an error.

386
00:23:18,000 --> 00:23:20,000
So then we need to fix this error by.

387
00:23:21,000 --> 00:23:25,000
I am hopeful that it will work.

388
00:23:25,000 --> 00:23:26,000
But let's see.

389
00:23:26,000 --> 00:23:27,000
What does it cost?

390
00:23:27,000 --> 00:23:30,000
So it can be downloading the V8 model.

391
00:23:31,000 --> 00:23:34,000
For the size of the model is 83.7.

392
00:23:34,000 --> 00:23:36,000
So quite large size.

393
00:23:36,000 --> 00:23:38,000
So it will take some time as well.

394
00:23:38,000 --> 00:23:46,000
So plus I'm running on or on CPU, so this will usually take more time than normal because on Google

395
00:23:46,000 --> 00:23:51,000
CoLab we have the free GPU available, but so the processing becomes very fast.

396
00:23:51,000 --> 00:23:57,000
But in that case don't have the GPU available so the things might get slow.

397
00:23:57,000 --> 00:24:01,000
But as it has started for the first epoch, it's fine.

398
00:24:02,000 --> 00:24:02,000
Okay.

399
00:24:02,000 --> 00:24:04,000
So I think there is an error.

400
00:24:04,000 --> 00:24:06,000
Let's see what the error is.

401
00:24:06,000 --> 00:24:07,000
Then we can fix it.

402
00:24:10,000 --> 00:24:12,000
Toward the end was a spacing issue over here.

403
00:24:12,000 --> 00:24:15,000
I just corrected it and just tested this script.

404
00:24:15,000 --> 00:24:16,000
It works fine.

405
00:24:16,000 --> 00:24:18,000
Let me show you the output as well.

406
00:24:19,000 --> 00:24:21,000
So I have just run the script.

407
00:24:21,000 --> 00:24:28,000
Python predict.py model v8.pt and it will take some time to execute.

408
00:24:28,000 --> 00:24:28,000
Okay.

409
00:24:28,000 --> 00:24:30,000
So now it has started.

410
00:24:31,000 --> 00:24:33,000
So I have set show is equal to true.

411
00:24:33,000 --> 00:24:39,000
So we have the output in the runtime so we can see the line currently.

412
00:24:39,000 --> 00:24:39,000
Okay.

413
00:24:39,000 --> 00:24:42,000
So here is the line which we have drawn.

414
00:24:42,000 --> 00:24:43,000
Okay.

415
00:24:43,000 --> 00:24:44,000
So.

416
00:24:45,000 --> 00:24:47,000
This is the object which is going to pass over here.

417
00:24:48,000 --> 00:24:50,000
Let's see if it does count or not.

418
00:24:51,000 --> 00:24:51,000
Okay.

419
00:24:52,000 --> 00:24:59,000
So that was important that there should be the count because we need our model to.

420
00:25:00,000 --> 00:25:09,000
Found as when like the when this so you can now please see this carefully when this line line this point

421
00:25:09,000 --> 00:25:13,000
this straight intersect with this line then we'll see the count.

422
00:25:16,000 --> 00:25:20,000
Okay, Let's see if there is a count or not.

423
00:25:21,000 --> 00:25:23,000
There is an error and then we will fix this.

424
00:25:24,000 --> 00:25:26,000
So when does testing on CPU?

425
00:25:26,000 --> 00:25:30,000
So you can imagine that the processing will be very slow.

426
00:25:31,000 --> 00:25:33,000
If you have a GPU, then this is great.

427
00:25:33,000 --> 00:25:34,000
You can test your model on the GPU.

428
00:25:36,000 --> 00:25:37,000
Well, okay.

429
00:25:37,000 --> 00:25:42,000
So whether this will intersect this point or not, let's.

430
00:25:43,000 --> 00:25:44,000
Okay.

431
00:25:44,000 --> 00:25:47,000
I think it might miss because it's going to dock.

432
00:25:50,000 --> 00:25:52,000
Okay, let's see.

433
00:25:52,000 --> 00:25:54,000
No, it will intersect shortly.

434
00:25:55,000 --> 00:25:56,000
Okay.

435
00:25:57,000 --> 00:25:58,000
I'm going to see an increment.

436
00:25:58,000 --> 00:25:58,000
Okay.

437
00:25:58,000 --> 00:26:03,000
So you can see that as this point intersect this line, we see a count.

438
00:26:03,000 --> 00:26:07,000
So when this car crosses this line, we will see the count as well.

439
00:26:07,000 --> 00:26:08,000
Okay.

440
00:26:08,000 --> 00:26:10,000
Let me show you other detecting.

441
00:26:10,000 --> 00:26:17,000
Not correctly the truck, but if you try with the YOLO V8 model, it will definitely detect it correctly.

442
00:26:17,000 --> 00:26:21,000
So let us see when the car crosses, what does it show us?

443
00:26:22,000 --> 00:26:25,000
Let's wait when the car crosses this line.

444
00:26:27,000 --> 00:26:30,000
So it might take a few seconds more.

445
00:26:30,000 --> 00:26:33,000
So let's wait for the guard to cross.

446
00:26:33,000 --> 00:26:34,000
So.

447
00:26:35,000 --> 00:26:37,000
And just waiting for the car to cross.

448
00:26:37,000 --> 00:26:43,000
And then we will move towards the next video tutorial in which we will be adding the speed estimation.

449
00:26:44,000 --> 00:26:45,000
Into it.

450
00:26:45,000 --> 00:26:47,000
So just waiting for the car.

451
00:26:47,000 --> 00:26:48,000
To cross this line.

452
00:26:48,000 --> 00:26:49,000
So.

453
00:26:50,000 --> 00:26:54,000
Uh, we can better see that the is coming from here.

454
00:26:54,000 --> 00:26:59,000
Are also incrementing the count over here.

455
00:26:59,000 --> 00:27:03,000
So it might take a few more seconds, so.

456
00:27:05,000 --> 00:27:08,000
And because I'm running a CPO, so the processing will definitely be slowed.

457
00:27:10,000 --> 00:27:15,000
In the next tutorial, I will add the speed estimation code in this script.

458
00:27:15,000 --> 00:27:17,000
So and then we will continue.

459
00:27:18,000 --> 00:27:20,000
From here, so they will not be much changing.

460
00:27:20,000 --> 00:27:26,000
So I will just add the speed estimation code in this script and no other thing will be changed.

461
00:27:27,000 --> 00:27:28,000
Okay.

462
00:27:28,000 --> 00:27:28,000
So.

463
00:27:29,000 --> 00:27:34,000
And it's just going to happen now so we can see over here.

464
00:27:35,000 --> 00:27:37,000
Like you can see now.

465
00:27:37,000 --> 00:27:40,000
Now this trail intersect this.

466
00:27:40,000 --> 00:27:42,000
Okay, So the color should change.

467
00:27:42,000 --> 00:27:43,000
Okay.

468
00:27:43,000 --> 00:27:45,000
So you can see the car counter here as well.

469
00:27:45,000 --> 00:27:50,000
So in this way, when this car pass, the car count will increase to two.

470
00:27:50,000 --> 00:27:54,000
When this car pass, the car count will increase to two.

471
00:27:54,000 --> 00:27:57,000
So in this way, all this process is happening.

472
00:27:57,000 --> 00:28:00,000
So I hope you have understood the main concept over here.

473
00:28:01,000 --> 00:28:04,000
See you all in the next video tutorial in the speed estimation.

474
00:28:05,000 --> 00:28:05,000
And then.

475
00:28:05,000 --> 00:28:06,000
Bye bye.

