1
00:00:02,670 --> 00:00:09,390
In this tutorial, we will be creating an application where I will be counting the persons entering

2
00:00:09,390 --> 00:00:11,610
and leaving from a specific area.

3
00:00:11,610 --> 00:00:18,810
Plus, I will also show you how you can count the number of vehicles entering and leaving from a specific

4
00:00:18,810 --> 00:00:20,220
area as well.

5
00:00:20,730 --> 00:00:27,750
So in this tutorial we will be doing objects counting and an object will be counting the objects entering

6
00:00:27,750 --> 00:00:29,490
and leaving from a specific area.

7
00:00:29,490 --> 00:00:32,430
And we will be creating two different applications.

8
00:00:32,430 --> 00:00:39,210
One is the upper one is the count of persons entering and leaving from a specific area, and the second

9
00:00:39,210 --> 00:00:44,610
one is the count of vehicles which are entering and leaving from a specific area.

10
00:00:44,610 --> 00:00:46,050
So let's get started with it.

11
00:00:46,050 --> 00:00:52,800
So in this tutorial, uh, with these applications I will be using Yolov5 and Deepsort object tracking

12
00:00:52,800 --> 00:00:53,490
algorithm.

13
00:00:53,790 --> 00:00:59,010
So you will be in a state of the art object detection algorithm, while, uh, Deepsort is the state

14
00:00:59,010 --> 00:01:01,980
of the art object tracking algorithm.

15
00:01:01,980 --> 00:01:02,190
Okay.

16
00:01:03,910 --> 00:01:10,150
So we will be integrating object detection and object tracking so that we can create a card counting

17
00:01:10,150 --> 00:01:13,030
application or vehicle counting application.

18
00:01:13,330 --> 00:01:19,510
Or you can say we will be, uh, counting the persons entering and leaving from a specific area.

19
00:01:19,510 --> 00:01:20,920
So there will be two applications.

20
00:01:20,920 --> 00:01:26,860
One is the persons entering and leaving, or the count of persons entering and leaving from a specific

21
00:01:26,860 --> 00:01:27,160
area.

22
00:01:27,160 --> 00:01:32,560
And the second one will be the count of vehicles entering and leaving from a specific area.

23
00:01:34,060 --> 00:01:38,260
So first of all, before we go ahead, uh, we have lost.

24
00:01:40,280 --> 00:01:42,470
So there are so.

25
00:01:43,560 --> 00:01:46,230
So before, uh, let's get started with it.

26
00:01:46,230 --> 00:01:51,930
So first of all, you can see over here I have the YOLO v nine repository or over here.

27
00:01:51,930 --> 00:01:55,140
So I will just first clone this YOLO nine GitHub repo.

28
00:01:55,140 --> 00:01:58,110
So I will just open the PyCharm from here.

29
00:01:58,950 --> 00:02:01,200
So you can see here the PyCharm ID.

30
00:02:01,230 --> 00:02:06,120
I've just created a new project by the name entering leaving counting your Deepsort recording.

31
00:02:06,120 --> 00:02:10,320
So you I've just created this project in my F local directory.

32
00:02:10,650 --> 00:02:11,220
Okay.

33
00:02:11,220 --> 00:02:13,230
So let's get started with it.

34
00:02:14,510 --> 00:02:18,650
So first of all, I just, uh, I will just note that you have the benign GitHub repository.

35
00:02:18,650 --> 00:02:22,070
So I will just add the link over here and write git clone.

36
00:02:24,250 --> 00:02:28,240
So now you can see that, uh, your login and GitHub repository has been cloned.

37
00:02:28,630 --> 00:02:29,110
Okay.

38
00:02:29,110 --> 00:02:32,290
So if I just refresh this over here.

39
00:02:34,170 --> 00:02:34,470
It.

40
00:02:37,760 --> 00:02:38,750
But it's not here.

41
00:02:39,110 --> 00:02:39,350
Okay.

42
00:02:39,350 --> 00:02:44,420
So you can see here we have the lone Euro v nine, uh, complete GitHub repository over here.

43
00:02:44,420 --> 00:02:49,820
So you can see all the files that we have in the repository are being here.

44
00:02:49,820 --> 00:02:55,580
So now I will just set this yolo v nine uh directory uh folder as my parent directory.

45
00:02:55,580 --> 00:02:58,910
So to do this I will just write CD which stands for current directory.

46
00:02:58,910 --> 00:03:02,870
And I will just set this folder as my current directory.

47
00:03:02,870 --> 00:03:04,130
And now it's being set.

48
00:03:04,130 --> 00:03:09,770
So before we go ahead let's create our virtual environment so you can create the virtual environment

49
00:03:09,770 --> 00:03:13,340
if you don't want to disturb your uh packages.

50
00:03:13,340 --> 00:03:16,580
So you will just write conda create minus n.

51
00:03:16,580 --> 00:03:20,270
And here I will just write the name of my virtual environment as v nine.

52
00:03:21,110 --> 00:03:21,620
Okay.

53
00:03:23,830 --> 00:03:27,490
So I am just creating a virtual environment by the name your Logging line.

54
00:03:28,240 --> 00:03:29,260
Okay, so.

55
00:03:32,500 --> 00:03:37,030
So you can see that it says that already a virtual environment by the name YOLO v9.

56
00:03:37,030 --> 00:03:39,670
So I've revoked that already created environment.

57
00:03:39,670 --> 00:03:41,710
And now I'm just waiting a new environment.

58
00:03:41,710 --> 00:03:48,250
So by the name of ignite and I will just write conda activate yolo v9.

59
00:03:48,670 --> 00:03:49,540
So that's it.

60
00:03:50,590 --> 00:03:53,800
So now I have just created a virtual world by the name yolo v9.

61
00:03:53,800 --> 00:04:01,420
And now I will install all the packages that are mentioned in the requirements.txt file.

62
00:04:01,420 --> 00:04:04,060
So over here you can see the requirements.txt file.

63
00:04:04,060 --> 00:04:10,060
In the requirements.txt file you will find all the packages uh, that are required to run this uh to

64
00:04:10,060 --> 00:04:12,940
run object detection object tracking scripts successfully.

65
00:04:15,150 --> 00:04:17,220
So if I just write pip install minus r.

66
00:04:17,220 --> 00:04:21,570
So this will install all the packages that are listed inside this requirements.txt file.

67
00:04:21,570 --> 00:04:25,260
So if you install these packages one by one this will take quite some time.

68
00:04:25,260 --> 00:04:30,510
So it's always a good practice to list all your packages in the requirements.txt file and books.

69
00:04:30,780 --> 00:04:35,160
And by writing one command in the terminal pip install minus r requirements.txt.

70
00:04:35,220 --> 00:04:40,500
So this install all the packages that are listed in the requirements dot txt file.

71
00:04:40,980 --> 00:04:43,890
So the package installation will take around 3 to 4 minutes.

72
00:04:43,890 --> 00:04:46,920
So let's get back as this packages gets drawn.

73
00:04:51,170 --> 00:04:54,320
Now you can see that all the packages are being installed.

74
00:04:54,320 --> 00:04:59,180
So the instructions are I've just created a notepad file by the name instruction.

75
00:04:59,510 --> 00:05:03,410
Here I have listed all the steps that we will be following in this tutorial.

76
00:05:03,410 --> 00:05:06,860
So now we have uploaded the nine GitHub repo.

77
00:05:06,860 --> 00:05:08,630
We have created a virtual environment.

78
00:05:08,630 --> 00:05:10,820
We have installed all the required packages.

79
00:05:10,820 --> 00:05:12,410
So three things are done.

80
00:05:12,410 --> 00:05:16,310
So now we will download the sample videos from the Google Drive link below.

81
00:05:16,310 --> 00:05:23,090
So I have added some uh videos or to test uh when we try to.

82
00:05:23,090 --> 00:05:29,990
So one is the person, uh, walking on a street and other are the vehicles on a highway lane so that

83
00:05:29,990 --> 00:05:35,000
we can, uh, count the vehicles entering and leaving and count the persons entering and leaving the

84
00:05:35,000 --> 00:05:35,900
specific area.

85
00:05:35,900 --> 00:05:39,140
So I have placed those demo videos onto my Google Drive.

86
00:05:39,140 --> 00:05:44,480
So I will directly download those demo videos from Google Drive into this PyCharm, uh, IDE.

87
00:05:44,690 --> 00:05:50,300
So to download the demo videos from, uh, Google Drive and directly into the PyCharm IDE, we need

88
00:05:50,300 --> 00:05:53,180
to install the pip install g down package.

89
00:05:53,450 --> 00:05:55,940
So I will just write over here pip install a down.

90
00:05:56,180 --> 00:06:01,700
And I will add this package in the uh requirements.txt file over here as well.

91
00:06:01,700 --> 00:06:02,360
So.

92
00:06:04,790 --> 00:06:06,980
Now you can see this package is installed.

93
00:06:06,980 --> 00:06:15,740
So this package now allows us to download any demo videos or any files or any image file or any video

94
00:06:15,740 --> 00:06:23,150
and image file or any, uh, other files, zip files from the Google Drive directly into our local IDE.

95
00:06:23,180 --> 00:06:28,550
It can be Visual Studio Video, it can be PyCharm, or it can be Orange Studio or any other IDE.

96
00:06:28,580 --> 00:06:35,390
Okay, so I've just added the write down and edit the link over here.

97
00:06:35,390 --> 00:06:42,890
So now you can see that uh, just watch that mp4 uh is downloaded into our PyCharm IDE.

98
00:06:43,100 --> 00:06:47,510
Or if I just refresh this up you can see the text box dot mp4 file over here.

99
00:06:47,510 --> 00:06:49,580
And let me just open this up.

100
00:06:49,580 --> 00:06:53,450
So now I will download the second demo video from the Google Drive.

101
00:06:53,630 --> 00:06:56,060
Like look directly into this PyCharm ID.

102
00:06:56,060 --> 00:06:58,340
So I will just add this link over here.

103
00:07:01,370 --> 00:07:04,400
So now you can see the second demo video is being downloaded.

104
00:07:04,790 --> 00:07:08,240
Uh, the name of this demo video is S3 dot mp4.

105
00:07:08,780 --> 00:07:13,970
Okay, so we, I have downloaded two demo videos and that would be enough to test our scripts.

106
00:07:14,360 --> 00:07:18,110
Okay so we have test for MP4 and testing.

107
00:07:22,310 --> 00:07:22,640
Okay.

108
00:07:22,640 --> 00:07:23,600
So here we have a test.

109
00:07:23,600 --> 00:07:24,080
We know that.

110
00:07:24,980 --> 00:07:26,390
So that's good enough.

111
00:07:26,390 --> 00:07:32,810
So now if we just see over here uh, I have cloned a GitHub repo, created a virtual environment, installed

112
00:07:32,810 --> 00:07:36,230
all the required packages, download the sample video.

113
00:07:36,230 --> 00:07:41,420
So I've downloaded two sample videos from the Google Drive into my PyCharm IDE as well.

114
00:07:41,420 --> 00:07:47,480
So now in next step, in the first step I will be doing object tracking using YOLO, v9 and Sword algorithm.

115
00:07:47,480 --> 00:07:49,190
So let's get started with it.

116
00:07:53,770 --> 00:07:54,220
Up here.

117
00:07:54,220 --> 00:07:58,540
You can see I've just created a file by the name detect-dual-tracking.py.

118
00:07:58,840 --> 00:08:02,590
Currently it only has the object detection board in the first step.

119
00:08:02,740 --> 00:08:08,350
I will integrate a Deepsort object tracking with yolo v9 object detection board over here.

120
00:08:08,350 --> 00:08:11,230
So currently this is all object detection code.

121
00:08:11,260 --> 00:08:16,810
We will first integrate object tracking and then we will be counting the person or vehicles entering

122
00:08:16,810 --> 00:08:17,980
and leaving in the next step.

123
00:08:17,980 --> 00:08:23,590
So object tracking using YOLO v9 and the source.

124
00:08:23,620 --> 00:08:25,420
So here right.

125
00:08:25,720 --> 00:08:30,340
So we will be doing object tracking using yolo v9 and Deepsort algorithm.

126
00:08:30,490 --> 00:08:35,200
So let me integrate object tracking board into this object detection board over here.

127
00:08:38,930 --> 00:08:41,870
The midfielders open the stands over here.

128
00:08:41,870 --> 00:08:44,360
So from the algorithm.

129
00:08:44,750 --> 00:08:50,030
The algorithm gives us output in the form of bounding box coordinates x one and y one represents the

130
00:08:50,570 --> 00:08:53,870
top, left corner and bounding box coordinates, and x two.

131
00:08:53,870 --> 00:08:57,920
Y two represents the bottom right corner bounding box coordinates.

132
00:08:57,920 --> 00:09:02,330
So this is the output uh, which we get from the algorithm.

133
00:09:02,330 --> 00:09:05,660
Plus we also get the confidence score and the class name okay.

134
00:09:05,660 --> 00:09:13,130
So but uh, we will be passing the output that we get from the algorithm as an input to the Deepsort

135
00:09:13,130 --> 00:09:13,640
algorithm.

136
00:09:13,640 --> 00:09:19,400
So the output that we get from the YOLO algorithm will be passed as an input to the Deepsort object

137
00:09:19,400 --> 00:09:20,360
tracking algorithm.

138
00:09:20,360 --> 00:09:26,090
So the Deepsort object tracking algorithm accepts uh, the input as height.

139
00:09:26,630 --> 00:09:27,650
And so.

140
00:09:28,420 --> 00:09:34,240
The Deepsort algorithm does not accept the bounding box coordinates like x one, y one or x two, y

141
00:09:34,270 --> 00:09:34,510
two.

142
00:09:34,540 --> 00:09:40,990
The Deepsort object tracking algorithm accepts input as the height and width of the bounding box.

143
00:09:40,990 --> 00:09:41,500
Okay.

144
00:09:41,530 --> 00:09:44,590
Last, the center point of the bounding box.

145
00:09:44,590 --> 00:09:49,090
So this is what our Deepsort object tracking algorithm accept as input.

146
00:09:49,330 --> 00:09:52,300
Along with this, accept a confidence score and class name.

147
00:09:52,300 --> 00:09:58,210
So the confidence score and class name are same uh, for the algorithm.

148
00:09:58,210 --> 00:10:02,920
But uh, the Yolo v nine algorithm gives us output in the form of bounding box coordinates.

149
00:10:02,920 --> 00:10:09,970
So Deepsort algorithm will not accept the, uh, output input uh, in the form of bounding box coordinates.

150
00:10:09,970 --> 00:10:14,530
So as we pass the yolo v nine output as an input to that Deepsort algorithm.

151
00:10:14,530 --> 00:10:22,120
So we need to convert this, uh, bounding box coordinates x one, y one and X2Y2 into this form like

152
00:10:22,120 --> 00:10:25,900
height and width of the bounding box and the center point of the bounding box.

153
00:10:25,900 --> 00:10:32,680
So before it pass the YOLO v nine output as an input to the Deepsort algorithm, we need to transform

154
00:10:32,680 --> 00:10:38,290
the Yolo nine output into the format that is required by the Deepsort algorithm, which is height and

155
00:10:38,290 --> 00:10:41,350
width of the bounding box and center coordinates of the bounding box.

156
00:10:41,710 --> 00:10:42,730
So let's do it.

157
00:10:58,620 --> 00:10:59,640
So x.

158
00:10:59,820 --> 00:11:02,520
So this is X1Y1 and X2Y2.

159
00:11:02,910 --> 00:11:03,480
Okay.

160
00:11:04,920 --> 00:11:07,170
So last we have the class names.

161
00:11:09,040 --> 00:11:09,280
Okay.

162
00:11:12,230 --> 00:11:14,690
But this is what we get from the revolving line output.

163
00:11:14,720 --> 00:11:17,450
So the output is currently in the form of tensors.

164
00:11:17,450 --> 00:11:20,630
We need to convert the output from tensors into integers.

165
00:11:55,350 --> 00:12:01,230
The next, we will find the center coordinates for each of the bounding box.

166
00:12:18,080 --> 00:12:22,190
So you can see over here we have find the center coordinates for each of the bounding box.

167
00:12:22,190 --> 00:12:27,770
As I told you, uh, that Deepsort algorithm accepts input as a center coordinates of the bounding box

168
00:12:27,770 --> 00:12:29,600
and height and width of the bounding box.

169
00:12:29,600 --> 00:12:32,510
So next we need to find the height and width of the bounding box.

170
00:12:33,140 --> 00:12:34,760
So I will just write.

171
00:12:53,090 --> 00:12:53,300
The.

172
00:12:58,730 --> 00:13:02,840
So here you can see that we have pointed out the width and the height of the bounding boxes.

173
00:13:02,960 --> 00:13:10,400
So, uh, if you just see over here so you can see here, uh, this is the x one minus x two.

174
00:13:10,520 --> 00:13:12,590
We do this, we get the width.

175
00:13:12,590 --> 00:13:15,110
And if we do y one minus y two we get the height.

176
00:13:15,440 --> 00:13:18,080
So I'm just following the same steps over here.

177
00:13:21,720 --> 00:13:26,910
So now, uh, as in a single frame, there will be multiple different objects will be detected.

178
00:13:26,910 --> 00:13:32,910
So now we will need to append this width and height and center coordinates of the bounding box for a

179
00:13:32,910 --> 00:13:34,440
complete frame into our list.

180
00:13:34,440 --> 00:13:35,760
So we will do this.

181
00:13:43,950 --> 00:13:46,470
I would create three empty lists over here.

182
00:13:55,560 --> 00:13:57,690
So this is what the bounding box coordinates.

183
00:13:57,690 --> 00:13:58,980
This is for the confidence score.

184
00:13:59,010 --> 00:14:02,280
This is for the class name and one we have for output as well.

185
00:14:17,960 --> 00:14:18,230
The.

186
00:14:24,210 --> 00:14:30,810
Got a Deepsort algorithm accept input as in the form of central coordinates Cxxvi bounding box coordinates.

187
00:14:30,810 --> 00:14:32,640
Width and height.

188
00:14:35,840 --> 00:14:41,270
Well, now I will just append these values to this list which we have created.

189
00:14:44,400 --> 00:14:47,160
Now I will also find out the quantum score for this.

190
00:14:47,160 --> 00:14:51,930
So I will just use for the math library so that I can convert the confidence score from tensors into

191
00:14:51,930 --> 00:14:52,380
integer.

192
00:14:56,010 --> 00:14:56,280
He.

193
00:15:02,560 --> 00:15:06,580
And now I will also open the scoring to the list which I have created above.

194
00:15:14,520 --> 00:15:18,060
And I'm just converting the class IDs into integers as well.

195
00:15:18,090 --> 00:15:21,900
Because they are originally in the form of tensors, we need to convert them into integers.

196
00:15:24,480 --> 00:15:28,110
And now I'm just spilling all the class ideas into the list as well.

197
00:15:34,090 --> 00:15:35,230
But now I'm just converted.

198
00:15:35,440 --> 00:15:42,400
Uh, so now I've just, uh, transformed my Yolo V8 output into the format that is required by the Deepsort

199
00:15:42,400 --> 00:15:43,000
algorithm.

200
00:15:43,030 --> 00:15:48,670
Like, you can see that I have the width and height and center coordinates of the bounding boxes.

201
00:15:48,670 --> 00:15:50,020
I have the confidence score.

202
00:15:50,080 --> 00:15:52,450
I have the class names as well.

203
00:15:52,450 --> 00:15:56,890
So now we need to convert, uh, this output into tensors.

204
00:15:56,980 --> 00:16:01,210
Uh, or this, uh, this, uh, output into dancers.

205
00:16:01,210 --> 00:16:04,780
And then we'll pass in this as an input to the Deepsort algorithm.

206
00:16:41,060 --> 00:16:41,300
Okay.

207
00:16:41,300 --> 00:16:44,180
So we have converted the this as.

208
00:16:45,140 --> 00:16:47,240
So we have going to just enter coordinates.

209
00:16:47,270 --> 00:16:51,080
Uh bounding boxes width and height into tensors that are required.

210
00:16:51,110 --> 00:16:55,700
We don't require to convert the class IDs into tensors currently.

211
00:16:57,380 --> 00:17:00,920
So I will just write output is equal to okay.

212
00:17:01,040 --> 00:17:03,350
So okay okay okay.

213
00:17:03,350 --> 00:17:07,790
So now I have not initialized with over here.

214
00:17:07,790 --> 00:17:10,400
So before we go ahead here.

215
00:17:16,420 --> 00:17:16,960
Over here.

216
00:17:16,960 --> 00:17:20,050
I've just created a file by the name object counter dot pi.

217
00:17:20,380 --> 00:17:23,560
So here you can see that I have class object counter.

218
00:17:23,560 --> 00:17:27,700
And over here I will explain this complete code which is over here.

219
00:17:27,700 --> 00:17:30,310
So first we have this initialize Deepsort.

220
00:17:30,310 --> 00:17:34,810
So first I will do what I will do here is okay.

221
00:17:34,810 --> 00:17:39,310
So I will just write from check out the import.

222
00:17:39,820 --> 00:17:42,250
So I will just import this class.

223
00:17:42,250 --> 00:17:47,260
So all the functions that we are required are inside this class okay.

224
00:17:47,830 --> 00:17:50,980
So I will just write object counter.

225
00:17:51,100 --> 00:17:53,920
Now I will just need to the initialization over here.

226
00:18:04,110 --> 00:18:04,530
Okay.

227
00:18:04,650 --> 00:18:05,760
We are good to go.

228
00:18:05,880 --> 00:18:06,720
Next I will write.

229
00:18:06,750 --> 00:18:08,490
Each sword is equal to.

230
00:18:11,170 --> 00:18:15,400
Object counter, and we will be using the initialized Deepsort function over here.

231
00:18:15,790 --> 00:18:16,390
Okay.

232
00:18:21,540 --> 00:18:24,720
So now what I will do is.

233
00:18:26,120 --> 00:18:29,330
Oh, well, I will just go over here.

234
00:18:30,610 --> 00:18:31,030
It's not.

235
00:18:31,420 --> 00:18:33,340
So if I just show you.

236
00:18:33,370 --> 00:18:37,420
Okay, so now I have don't have added the Deepsort files over here as well.

237
00:18:37,420 --> 00:18:39,640
So let me add those Deepsort files.

238
00:18:40,360 --> 00:18:43,150
And so I haven't added the link over here.

239
00:18:43,150 --> 00:18:43,690
So.

240
00:18:46,520 --> 00:18:50,780
Before we write the sixth and seventh step, we need to add.

241
00:18:51,980 --> 00:18:53,690
We need to download.

242
00:18:54,880 --> 00:18:58,270
That Deepsort files are.

243
00:19:00,370 --> 00:19:01,210
Right.

244
00:19:02,530 --> 00:19:02,950
It.

245
00:19:08,300 --> 00:19:09,170
We can see here.

246
00:19:09,170 --> 00:19:10,910
I did a Google Drive link.

247
00:19:10,910 --> 00:19:16,250
I have pasted each zip file in this Google Drive link on this Google Drive link, so I will actually

248
00:19:16,250 --> 00:19:21,620
download a zip file from this Google Drive link into my PyCharm ID, and then I will unzip this file.

249
00:19:22,340 --> 00:19:22,820
Okay.

250
00:19:26,100 --> 00:19:30,990
So I'm downloading this deepsort zip file from the Google Drive directly into this PyCharm IDE.

251
00:19:30,990 --> 00:19:35,340
And uh, now you can see the file size is 43.1 MB.

252
00:19:35,340 --> 00:19:38,640
And as I as it gets downloaded I will unzip this file.

253
00:19:42,030 --> 00:19:42,300
Okay.

254
00:19:42,300 --> 00:19:44,580
So now you can see the file is being downloaded.

255
00:19:44,610 --> 00:19:47,250
Let me just unzip it.

256
00:19:50,550 --> 00:19:52,200
So now unzip that file.

257
00:19:52,200 --> 00:19:55,650
So let's go ahead and you can see I have this file over here.

258
00:19:55,650 --> 00:20:01,140
So if I just open the deepsort uh.py code over here.

259
00:20:01,140 --> 00:20:04,140
So now you can see here we have the class deepsort.

260
00:20:04,140 --> 00:20:06,720
And here we have the initialize function over here.

261
00:20:06,720 --> 00:20:10,500
And I will be using this Deepsort dot update function.

262
00:20:10,500 --> 00:20:12,750
And here I am this update function.

263
00:20:12,750 --> 00:20:17,670
Now you can see that we have the input in the form of bounding box coordinates and width.

264
00:20:17,670 --> 00:20:23,520
And uh, we have the input in the form of width and the height of the bounding box and center coordinates

265
00:20:23,520 --> 00:20:24,960
of the bounding boxes.

266
00:20:24,960 --> 00:20:31,500
Plus we have the confidence score and the class name and the original frame as the input of this update

267
00:20:31,500 --> 00:20:31,980
function.

268
00:20:31,980 --> 00:20:32,730
So that's good.

269
00:20:35,010 --> 00:20:40,950
So I will be using this Deepsort dot update function and in the import over here.

270
00:20:43,570 --> 00:20:44,980
In the input over here.

271
00:20:44,980 --> 00:20:49,600
I will be passing this center coordinates of the bounding box bounding box width and the bounding box

272
00:20:49,600 --> 00:20:49,930
height.

273
00:20:49,930 --> 00:20:52,630
And we have all this inside this.

274
00:20:55,860 --> 00:21:02,550
Inside this because we have converted the this into tensors, and now we are passing this as an input

275
00:21:02,550 --> 00:21:05,190
to the data sort update function.

276
00:21:05,790 --> 00:21:06,510
Okay.

277
00:21:06,690 --> 00:21:08,250
For the input ready sort algorithm.

278
00:21:08,250 --> 00:21:14,670
Plus we will be passing the confidence port and the class IDs.

279
00:21:22,130 --> 00:21:26,090
And we will be passing the grand frame which I have already shown.

280
00:21:26,630 --> 00:21:33,290
Okay, so this will be the input to the deep sort algorithm, and we will be passing this to that update

281
00:21:33,290 --> 00:21:35,090
function that I've already shown you.

282
00:21:40,790 --> 00:21:45,860
So next what we'll do is we have the length of the outputs greater than zero.

283
00:21:45,860 --> 00:21:52,100
Like if there are some objects, if any of the object is directly in the current frame, like 1 or 2,

284
00:21:53,270 --> 00:21:54,440
then what we.

285
00:21:54,440 --> 00:21:54,800
Right.

286
00:21:54,800 --> 00:22:01,010
So I mean, so if you just print out the output from here.

287
00:22:09,270 --> 00:22:12,030
Let me show you how our output looks like.

288
00:22:21,370 --> 00:22:25,360
Thought we were just running this detect as dual tracking, not by script.

289
00:22:25,780 --> 00:22:34,420
And that we just got this text box, not MP4 video, which we have downloaded already from the Google

290
00:22:34,420 --> 00:22:34,900
Drive link.

291
00:22:34,900 --> 00:22:38,230
So let me show you.

292
00:22:38,230 --> 00:22:41,320
So if I just show you here.

293
00:22:43,370 --> 00:22:49,310
From the Deepsort algorithm like we have passed it in the in as a center coordinates of the bounding

294
00:22:49,310 --> 00:22:55,790
boxes and width and the height of the bounding boxes as an input to the dot algorithm and from the from

295
00:22:55,790 --> 00:22:57,650
the output of the algorithm.

296
00:22:57,830 --> 00:22:59,660
What we get is the bounding box coordinates.

297
00:22:59,660 --> 00:23:02,540
So this is the output of the Deepsort algorithm.

298
00:23:02,540 --> 00:23:05,480
We get the bounding box coordinates a unique ID.

299
00:23:05,480 --> 00:23:09,560
Basically, in object tracking we assign a unique ID to each of the detected object.

300
00:23:09,560 --> 00:23:12,920
So we get the unique ID for each of the detected object.

301
00:23:12,920 --> 00:23:16,250
Plus we get the class name or class IDs.

302
00:23:16,250 --> 00:23:18,860
For example, for the person class, the class ID is zero.

303
00:23:18,860 --> 00:23:24,170
So the Deepsort algorithm returns us the bounding box coordinates like x one, y one, and x two, y

304
00:23:24,170 --> 00:23:29,300
two that are the top left corner bounding box coordinate and bottom right corner bounding box coordinates.

305
00:23:29,300 --> 00:23:32,810
Along with this Deepsort algorithm, output gives us signs.

306
00:23:32,810 --> 00:23:37,760
In the Deepsort algorithm output, we get a unique ID for each of the detected object.

307
00:23:37,760 --> 00:23:39,530
Basically, this is what object tracking do.

308
00:23:39,530 --> 00:23:42,950
In object tracking, we assign a unique ID to each detected object.

309
00:23:42,950 --> 00:23:44,570
Thus we get the class ID.

310
00:23:44,570 --> 00:23:47,420
For example, for the person class, the class ID is zero.

311
00:23:47,690 --> 00:23:50,900
So this is the output that we get from the Deepsort algorithm.

312
00:23:53,660 --> 00:23:54,590
Love it.

313
00:24:01,290 --> 00:24:04,590
So I have got the idea for this error because.

314
00:24:06,600 --> 00:24:10,260
So we just layer this over here.

315
00:24:13,190 --> 00:24:13,490
It.

316
00:24:16,000 --> 00:24:16,810
The.

317
00:24:17,890 --> 00:24:19,300
Okay, so now it's working.

318
00:24:19,300 --> 00:24:19,810
Okay.

319
00:24:20,230 --> 00:24:23,350
So now I think.

320
00:24:29,950 --> 00:24:30,370
Yeah.

321
00:24:30,370 --> 00:24:31,810
Hopefully it will work fine.

322
00:24:36,530 --> 00:24:38,240
Let's see how it goes.

323
00:24:39,170 --> 00:24:41,330
I think now the issue will be solved.

324
00:24:42,470 --> 00:24:43,850
Okay, so.

325
00:24:51,370 --> 00:24:55,510
Okay, so we also need to run the Deepsort algorithm step.

326
00:24:55,510 --> 00:24:59,620
We need to have the easy dish package installed as well.

327
00:24:59,620 --> 00:25:01,690
So I try to.

328
00:25:04,150 --> 00:25:08,770
Then I can just, like, maybe start easy then.

329
00:25:09,640 --> 00:25:09,880
Yeah.

330
00:25:10,840 --> 00:25:12,220
So I run over here as well.

331
00:25:12,220 --> 00:25:14,440
So if you just install all these packages.

332
00:25:14,770 --> 00:25:20,380
Uh, if you run install the requirements.txt file, this package will also get installed along the way.

333
00:25:21,490 --> 00:25:22,780
So let's run this up.

334
00:25:28,900 --> 00:25:34,090
So this will take a few seconds because on my local system I don't have GPU, I have CPU, so I'm running

335
00:25:34,090 --> 00:25:34,810
on CPU.

336
00:25:44,800 --> 00:25:44,980
A.

337
00:25:48,630 --> 00:25:52,590
Or last one will have the output being shown over here.

338
00:25:58,880 --> 00:25:59,210
Okay.

339
00:25:59,210 --> 00:26:02,120
So last data packet is shown.

340
00:26:02,120 --> 00:26:08,870
Like let me just correct this up over here as well where I have num pi.

341
00:26:12,680 --> 00:26:14,030
It's all we need to have.

342
00:26:14,030 --> 00:26:14,810
NumPy.

343
00:26:15,320 --> 00:26:17,570
Less than 1.24.

344
00:26:17,600 --> 00:26:19,820
Else will give an error log.

345
00:26:19,880 --> 00:26:24,290
Okay, so we will I will first uninstall numpy.

346
00:26:28,740 --> 00:26:31,590
Because with the latest version of numpy we get error.

347
00:26:31,590 --> 00:26:33,900
So we'll just downgrade the one version.

348
00:26:34,980 --> 00:26:35,790
So.

349
00:26:40,050 --> 00:26:43,980
Or you just install numpy with version less than.

350
00:26:45,800 --> 00:26:48,650
1.2 score.

351
00:26:49,550 --> 00:26:52,160
Okay, so I hope this will fix up the issue.

352
00:27:39,120 --> 00:27:42,480
Currently there is no output was.

353
00:27:42,480 --> 00:27:45,810
As we go out in the next frame we will be able to see the output.

354
00:27:45,810 --> 00:27:48,570
I am not showing displaying the output currently.

355
00:27:49,230 --> 00:27:50,880
Okay, so now you can see here.

356
00:27:50,880 --> 00:27:59,550
Uh, so this is the output that we get from the uh sort algorithm like you can see over here.

357
00:28:03,750 --> 00:28:07,770
So this is the output that we are getting from the Deepsort algorithm, so that these are the bounding

358
00:28:07,770 --> 00:28:08,850
box coordinates.

359
00:28:09,270 --> 00:28:09,930
Okay.

360
00:28:10,260 --> 00:28:14,760
Here you can see this is a unique ID that is being assigned to each of the detected object.

361
00:28:14,760 --> 00:28:16,920
And here we have the class IDs.

362
00:28:16,920 --> 00:28:19,380
For example for the person class the class ID zero.

363
00:28:19,380 --> 00:28:23,250
So these are the bounding box coordinates X1Y1X2Y2.

364
00:28:23,490 --> 00:28:28,200
This is the unique ID like in object tracking we assign a unique ID to each of the detected object.

365
00:28:28,200 --> 00:28:28,740
So the.

366
00:28:28,740 --> 00:28:30,480
Here the unique id is one.

367
00:28:30,480 --> 00:28:32,820
Here for the second object the unique id is two.

368
00:28:32,880 --> 00:28:34,650
For the third object, unique id is four.

369
00:28:34,650 --> 00:28:38,670
And this is the class ID for the person class.

370
00:28:38,670 --> 00:28:40,410
The class ID is zero.

371
00:28:40,410 --> 00:28:40,800
Okay.

372
00:28:40,800 --> 00:28:43,020
So if I just show you over here.

373
00:28:44,070 --> 00:28:48,600
So the Deepsort algorithm gives us the bounding box coordinates, a unique ID for each of the detected

374
00:28:48,600 --> 00:28:48,990
object.

375
00:28:48,990 --> 00:28:50,640
Plus we get the class IDs.

376
00:28:50,880 --> 00:28:54,570
For example, for the person class the class id zero okay.

377
00:28:54,570 --> 00:28:57,330
So this is for what we are getting for each of the frame.

378
00:28:57,330 --> 00:29:00,720
Like the complete video is divided into 341 frames.

379
00:29:00,720 --> 00:29:03,690
And we are doing detection on each of the frame one by one.

380
00:29:03,690 --> 00:29:07,980
And we are getting the bounding box coordinates unique ID for each of the detected object.

381
00:29:07,980 --> 00:29:10,410
Thus we are getting the class IDs as well.

382
00:29:14,190 --> 00:29:14,580
Okay.

383
00:29:14,580 --> 00:29:15,480
So.

384
00:29:21,980 --> 00:29:26,810
If the length of the output is greater than zero.

385
00:29:42,430 --> 00:29:45,010
The first four are presenting the bounding box coordinates.

386
00:29:46,600 --> 00:29:52,720
Then the second last basically represents the unique ID that we assign to each of the detected object.

387
00:29:57,770 --> 00:30:01,640
And the last one represents the object ID or the class ID.

388
00:30:08,540 --> 00:30:12,530
Okay, so if I just go to the object counter.py file.

389
00:30:12,530 --> 00:30:19,490
So over here you can see that I have created draw boxes function that will draw bounding box coordinates

390
00:30:19,610 --> 00:30:21,200
around each of the detected object.

391
00:30:21,200 --> 00:30:25,070
Plus will add the unique ID that is being assigned to each of the detected object.

392
00:30:25,070 --> 00:30:27,050
Plus will also add the class names.

393
00:30:27,710 --> 00:30:33,350
So I will just write draw dash boxes or I will just write.

394
00:30:34,580 --> 00:30:39,650
So if I just go above over here so we have object counter.

395
00:30:43,470 --> 00:30:45,660
I will assign draw dash boxes.

396
00:30:47,010 --> 00:30:49,380
We have the front frame over here.

397
00:30:50,530 --> 00:30:54,580
Lasts will pass down the warning box or nets.

398
00:30:54,970 --> 00:30:56,440
It was the IDs.

399
00:30:59,580 --> 00:31:00,420
You need guidance.

400
00:31:00,420 --> 00:31:02,970
Plus will class the class ylist here.

401
00:31:03,240 --> 00:31:07,500
Okay, so if I just go to the object counter.py file.

402
00:31:07,500 --> 00:31:12,360
So let me explain you this complete code from the start very start.

403
00:31:12,360 --> 00:31:16,170
So over here you can see that here we have created a function by the name.

404
00:31:16,200 --> 00:31:16,710
Uh okay.

405
00:31:16,710 --> 00:31:18,690
Let's start from the initialization step.

406
00:31:18,690 --> 00:31:22,230
So here I am just creating a line by the name self dot line.

407
00:31:22,380 --> 00:31:22,890
Okay.

408
00:31:23,100 --> 00:31:28,170
So in this uh, dot nine or I am just passing the coordinates for the line.

409
00:31:28,170 --> 00:31:31,110
So let me show you how does it works.

410
00:31:33,590 --> 00:31:34,070
At this.

411
00:31:35,890 --> 00:31:40,810
So for example, this is the video in which I will be doing vehicle scouting.

412
00:31:40,810 --> 00:31:43,240
I will be counting the vehicles entering and leaving.

413
00:31:43,240 --> 00:31:45,700
So I am just creating a line over here.

414
00:31:45,700 --> 00:31:46,480
You can see that.

415
00:31:46,480 --> 00:31:49,300
So when the vehicles passes by this line.

416
00:31:49,300 --> 00:31:54,340
So I will say like this vehicle passes by this time I will say that this vehicle is.

417
00:31:56,520 --> 00:32:00,180
So when this vehicle passes first line, I will say that this vehicle is leaving.

418
00:32:00,570 --> 00:32:01,230
Okay.

419
00:32:01,230 --> 00:32:07,620
And when the vehicle coming from here passes by this line, I will say that this vehicle is entering.

420
00:32:07,650 --> 00:32:09,900
So the vehicle passes by.

421
00:32:09,900 --> 00:32:11,910
I say that vehicle is leaving the lane.

422
00:32:11,910 --> 00:32:18,000
And when the vehicle over here on this lane passes by this line, I will say that vehicle is entering

423
00:32:18,000 --> 00:32:18,450
the lane.

424
00:32:18,450 --> 00:32:18,960
Okay.

425
00:32:19,440 --> 00:32:22,170
So we have this creating a line.

426
00:32:22,170 --> 00:32:23,370
And here I have this.

427
00:32:23,490 --> 00:32:24,900
If you just record this.

428
00:32:24,900 --> 00:32:28,260
So if you just focus over here in that spot where my cursor is.

429
00:32:28,710 --> 00:32:29,340
Okay.

430
00:32:29,340 --> 00:32:36,060
At this point where my question is so you can see if I just go over here, this will be the one to explain

431
00:32:36,060 --> 00:32:39,870
the the first endpoint coordinates of the line.

432
00:32:39,870 --> 00:32:45,870
And so if I just go over here this gave me the second and third point coordinates for this line okay.

433
00:32:45,870 --> 00:32:48,090
So these are the first endpoint coordinates.

434
00:32:48,090 --> 00:32:50,790
And these are the second and third borders for this line.

435
00:32:50,790 --> 00:32:54,120
And you can see those values over here okay.

436
00:32:56,120 --> 00:33:00,740
So you can see that I have this pass on the first endpoint coordinates of the lines values over here.

437
00:33:00,740 --> 00:33:04,040
And these represent the second endpoint coordinates of the line okay.

438
00:33:04,040 --> 00:33:08,300
Plus we are just creating a dictionary over here uh, by the name entering and leaving.

439
00:33:08,300 --> 00:33:10,280
And in the end conditioning dictionary.

440
00:33:10,280 --> 00:33:17,090
We are storing the vehicles or the persons entering, uh, the lane over and thus leaving their dictionary.

441
00:33:17,090 --> 00:33:21,230
We are this will restore the person or vehicles leaving the lane.

442
00:33:21,230 --> 00:33:25,280
And I'm just creating another dictionary by the name Delta Dash DK.

443
00:33:25,280 --> 00:33:31,040
Okay, so here I have just mentioned all the classes name that we have in the Coco data set.

444
00:33:31,040 --> 00:33:36,410
So the Coco or YOLO model has been pre-trained trained on the Coco data set.

445
00:33:36,410 --> 00:33:39,260
And Coco dataset consists of 80 different classes.

446
00:33:39,260 --> 00:33:44,480
So uh, if we have the class id zero, this means it belongs to the person class.

447
00:33:44,480 --> 00:33:47,960
If we have the class id one, it means that it belongs to the bicycle class.

448
00:33:47,960 --> 00:33:50,570
If we have the class 82, it belongs to the car class.

449
00:33:50,570 --> 00:33:56,510
And if we have the class ID four, uh, if we have the class ID three, it belongs to the motorbike

450
00:33:56,510 --> 00:33:56,900
class.

451
00:33:56,900 --> 00:33:57,380
Okay.

452
00:33:58,700 --> 00:34:02,870
And if we have the class ID as 79, then it locks the toothbrush class.

453
00:34:02,870 --> 00:34:07,460
So we start with zero and end at 79.

454
00:34:07,460 --> 00:34:08,060
Okay.

455
00:34:08,060 --> 00:34:12,290
So the class would class ID zero means that it belongs to the person class.

456
00:34:12,290 --> 00:34:14,300
Class ID one means it blocks the bicycle.

457
00:34:14,300 --> 00:34:17,060
Class 82 means blocks of the car class.

458
00:34:17,060 --> 00:34:20,600
Then we have the complete color code labels function.

459
00:34:20,600 --> 00:34:27,350
So if the class ID or label is zero, then it means it belongs to the person class and the bounding

460
00:34:27,350 --> 00:34:29,090
box will have the green color.

461
00:34:29,090 --> 00:34:34,730
If the class ID is two, then it means it belongs to the car class, and the bounding box will have

462
00:34:34,730 --> 00:34:35,720
the following color.

463
00:34:35,720 --> 00:34:40,850
If the class ID is three blocks, the motorbike class and the bounding box will have the the following

464
00:34:40,850 --> 00:34:41,210
color.

465
00:34:41,210 --> 00:34:48,200
If the class ID is five, then it belongs to the bus class and the bounding box will have the following

466
00:34:48,200 --> 00:34:48,440
color.

467
00:34:48,440 --> 00:34:54,620
And if, uh, the class ID doesn't belong to either of these classes, then we will assign that this

468
00:34:54,620 --> 00:34:56,240
following color to the bounding boxes.

469
00:34:56,240 --> 00:35:01,160
Okay, so here I have displayed the initialized Deepsort function where we are just initializing the

470
00:35:01,160 --> 00:35:02,870
Deepsort tracker over here.

471
00:35:02,870 --> 00:35:07,250
And here we have the speed at deepsort configuration of the object.

472
00:35:07,250 --> 00:35:13,430
And we have, uh, where we have loaded all the settings from the Deepsort dot yml file over here.

473
00:35:14,870 --> 00:35:21,650
Okay, so now, uh, what we will say over here is, um, so now here you can see we have the intersect

474
00:35:21,650 --> 00:35:22,190
function.

475
00:35:22,190 --> 00:35:22,640
Okay.

476
00:35:22,640 --> 00:35:24,530
So what does this do?

477
00:35:25,160 --> 00:35:25,730
Okay.

478
00:35:28,640 --> 00:35:35,750
So we are just saying that over here, when the slide, you consider where the center point of the bounding

479
00:35:35,750 --> 00:35:40,940
box, like you can see here, we have the center point of the bounding box and the center point of the

480
00:35:40,940 --> 00:35:41,720
bounding box.

481
00:35:41,720 --> 00:35:48,620
The exact with this line over here, then we will count or we will say that the, uh, volume vehicle

482
00:35:48,620 --> 00:35:49,250
is leaving.

483
00:35:49,250 --> 00:35:55,340
And when the center point of this car coming from here intersect with this line, then we will say the

484
00:35:55,340 --> 00:35:56,690
car is entering the lid.

485
00:35:57,230 --> 00:35:59,630
And when the center point of the.

486
00:36:04,120 --> 00:36:10,840
If the vehicle coming over a car coming from this lane in this sect with this line so that center point

487
00:36:10,840 --> 00:36:16,780
of the vehicle or the car intersect with this line, then we will say, uh, the vehicle is leaving.

488
00:36:16,780 --> 00:36:17,320
Okay.

489
00:36:17,320 --> 00:36:23,650
So when the center point of the vehicle intersect in this line, then you will say a vehicle is leaving.

490
00:36:23,650 --> 00:36:30,790
So if I just open over here, so, like, okay, uh, I can check if two segments intersect.

491
00:36:30,790 --> 00:36:33,730
So there is I found out the solution for the chord over here.

492
00:36:33,730 --> 00:36:38,350
So basically we need to find out how the two lines intersect.

493
00:36:38,350 --> 00:36:41,440
So here we have the intersect chord over here.

494
00:36:41,440 --> 00:36:44,680
So if the two lines intersect so here we have the chord.

495
00:36:44,680 --> 00:36:47,740
So I will be using this piece of code from here.

496
00:36:49,490 --> 00:36:56,180
Okay, so now you can see that I've just added this code over here to find the intersection between

497
00:36:56,180 --> 00:36:59,240
the center point of the vehicle and the line, which I have drawn.

498
00:36:59,270 --> 00:37:01,550
If so.

499
00:37:02,610 --> 00:37:08,160
I will be finding the intersection for the center point of the London line, which have brought it over

500
00:37:08,160 --> 00:37:08,520
here.

501
00:37:10,420 --> 00:37:13,420
So now I have just created a function by the name get prediction.

502
00:37:13,420 --> 00:37:16,210
So uh, what I will say that, uh.

503
00:37:18,410 --> 00:37:20,030
If I just open over here.

504
00:37:20,030 --> 00:37:25,400
So if the vehicle is going into this direction, like this is a north direction.

505
00:37:27,500 --> 00:37:28,130
Okay.

506
00:37:28,340 --> 00:37:30,470
Or if let me just, uh.

507
00:37:31,070 --> 00:37:35,480
So if the vehicle is going into this direction, this is a north direction.

508
00:37:35,480 --> 00:37:36,050
Okay.

509
00:37:36,170 --> 00:37:41,960
And so when the vehicle goes into the north direction, we will say the vehicles are entering.

510
00:37:41,960 --> 00:37:48,290
And if the vehicle goes into this direction which is the south direction, then we will say the vehicles

511
00:37:48,290 --> 00:37:50,150
are leaving the lane.

512
00:37:50,180 --> 00:37:50,720
Okay.

513
00:37:50,720 --> 00:37:55,970
So if the vehicles go into the north direction over here, then you'll say the vehicles are entering.

514
00:37:55,970 --> 00:38:02,300
And if the vehicles go over here, then we will say south direction.

515
00:38:02,300 --> 00:38:03,920
The vehicles are leaving.

516
00:38:03,920 --> 00:38:08,210
And if the vehicles causing the north direction then we'll say the vehicles are entering.

517
00:38:08,750 --> 00:38:09,230
Okay.

518
00:38:11,150 --> 00:38:12,950
So we will find out the direction.

519
00:38:12,950 --> 00:38:15,710
So how we can find out the direction okay.

520
00:38:15,710 --> 00:38:22,940
So let me just tell you how we can find out that direction like in which direction the vehicles are

521
00:38:22,940 --> 00:38:23,660
traveling.

522
00:38:26,010 --> 00:38:28,290
If you go to the drop boxes function.

523
00:38:28,290 --> 00:38:30,630
So over here you can see that we are.

524
00:38:30,840 --> 00:38:34,680
So here you can see that we have created a dictionary by the name data Dash dk.

525
00:38:34,680 --> 00:38:38,070
And uh here you can see that we are just defining it.

526
00:38:38,100 --> 00:38:40,470
DK so DK is basically a list.

527
00:38:40,470 --> 00:38:47,580
Or you can say DK is preferred over list in the cases where we need to quicker in or pop operations.

528
00:38:47,610 --> 00:38:48,030
Okay.

529
00:38:48,030 --> 00:38:52,530
So where we need a quicker in and pop operation where we prefer DK over list.

530
00:38:52,530 --> 00:38:58,770
So DK is just a list and we are just defining the maximum length of this big list will be 64.

531
00:38:58,950 --> 00:38:59,340
Okay.

532
00:38:59,340 --> 00:39:06,090
Over here and in this data DK, we are just appending our center coordinates of the bounding boxes.

533
00:39:06,120 --> 00:39:06,690
Okay.

534
00:39:06,690 --> 00:39:11,340
And in the data DK we are just appending the center coordinates of the bounding boxes.

535
00:39:11,340 --> 00:39:16,890
So let me just, uh, print this out to show you how we will find out the direction.

536
00:39:20,230 --> 00:39:20,560
It.

537
00:39:20,950 --> 00:39:22,930
Let me just run this from the.

538
00:39:25,890 --> 00:39:26,100
It.

539
00:39:28,340 --> 00:39:28,550
The.

540
00:39:33,160 --> 00:39:35,590
So this will take a few seconds.

541
00:39:44,250 --> 00:39:46,260
Um, let us wait for this.

542
00:39:52,650 --> 00:39:52,830
The.

543
00:39:57,030 --> 00:39:57,840
So.

544
00:40:03,050 --> 00:40:03,380
It.

545
00:40:06,740 --> 00:40:08,570
Okay, so I have the data enough.

546
00:40:08,570 --> 00:40:10,310
So let me just show you how the zero.

547
00:40:12,670 --> 00:40:16,120
Okay, so if I just open this up over here.

548
00:40:16,120 --> 00:40:20,170
So now you can see if I just go about about.

549
00:40:33,540 --> 00:40:34,260
So okay.

550
00:40:34,260 --> 00:40:40,530
For here, you can see that, uh, this is basically the unique ID for each of the object which we have.

551
00:40:40,560 --> 00:40:40,980
Okay.

552
00:40:40,980 --> 00:40:44,580
And here we have the dequeue list which you can find over here okay.

553
00:40:44,580 --> 00:40:47,790
And the maximum length of this list is 64 okay.

554
00:40:47,790 --> 00:40:55,710
So now you can see that uh, here we have in the dequeue list, we have more than two different iterations

555
00:40:55,710 --> 00:40:56,250
over here.

556
00:40:56,250 --> 00:41:02,400
Like you can see that if the log here we have added a condition if the length or the data id.

557
00:41:02,400 --> 00:41:09,090
So here you can see that for the ID one the length is equal to two.

558
00:41:09,120 --> 00:41:12,030
Like we have two different iterations over here.

559
00:41:12,540 --> 00:41:15,270
So now what how we can find out the direction okay.

560
00:41:15,270 --> 00:41:21,600
So over here you can see that if the point one is greater than point two okay.

561
00:41:21,600 --> 00:41:28,080
So if the first index of the point one is greater than the first index of the point two okay.

562
00:41:28,080 --> 00:41:31,710
So like this is the first index of the point one.

563
00:41:31,710 --> 00:41:34,020
And this is the first index of the point two.

564
00:41:34,380 --> 00:41:40,380
So over here I'm just passing the data dequeue ID zero and ID one okay.

565
00:41:40,380 --> 00:41:43,080
So this is the data dequeue ID zero.

566
00:41:43,080 --> 00:41:46,410
And this is the data dequeue ID one okay.

567
00:41:46,410 --> 00:41:47,160
So.

568
00:41:48,840 --> 00:41:49,350
Over here.

569
00:41:49,350 --> 00:41:54,780
And we are just finding using the first index which we have defined over here, like we are just considering

570
00:41:54,780 --> 00:41:55,920
out the first index.

571
00:41:55,920 --> 00:42:02,010
So the first index will be this one and this one okay.

572
00:42:02,460 --> 00:42:03,480
So both of these.

573
00:42:03,480 --> 00:42:10,440
So we are saying that if the like here the 783 is greater than 782.

574
00:42:10,440 --> 00:42:14,760
So this means like here you can see that 783 is greater than 782.

575
00:42:14,760 --> 00:42:20,700
So this means the our object or the vehicle or the person is traveling in the south direction.

576
00:42:20,700 --> 00:42:26,670
So if I just show you so this means the vehicle or person is traveling in the south direction which

577
00:42:26,670 --> 00:42:28,770
means the vehicle is leaving.

578
00:42:30,120 --> 00:42:30,540
Okay.

579
00:42:30,690 --> 00:42:37,440
If this, uh, point one is less than point two, like here, the country, the point one is greater

580
00:42:37,440 --> 00:42:38,040
than point two.

581
00:42:38,040 --> 00:42:40,410
So this is traveling the south south direction.

582
00:42:40,410 --> 00:42:44,340
But, uh, let me consider another case where this is happening.

583
00:42:44,340 --> 00:42:44,970
Okay.

584
00:42:45,630 --> 00:42:47,040
Like here you can see that.

585
00:42:47,040 --> 00:42:54,450
So 137 so here you can see that point one is less than point two.

586
00:42:54,480 --> 00:42:59,970
So that you can say that vehicle or the person is traveling in the north direction okay.

587
00:43:00,150 --> 00:43:00,900
So.

588
00:43:05,100 --> 00:43:08,370
What if we say the vehicle over the person is traveling the north direction?

589
00:43:08,370 --> 00:43:12,540
Then we are saying that the person is entering or the vehicle is entering.

590
00:43:12,540 --> 00:43:16,860
When we say the person or the vehicle is traveling the south direction, we can we are saying that the

591
00:43:16,860 --> 00:43:18,510
person or the vehicle is leaving.

592
00:43:18,540 --> 00:43:20,970
Okay, so how we can find out.

593
00:43:20,970 --> 00:43:26,430
Like you can see over here, 783 is greater than 782.

594
00:43:26,430 --> 00:43:32,970
So we are just saying that it's traveling in the South direction because 783 represents the latest represent

595
00:43:32,970 --> 00:43:34,140
the latest iteration.

596
00:43:34,140 --> 00:43:35,700
And this is the previous side.

597
00:43:36,000 --> 00:43:40,440
Like uh so here this is one represent the latest iteration.

598
00:43:40,440 --> 00:43:40,890
Okay.

599
00:43:41,190 --> 00:43:46,650
So if I just open this over here like you can see over here, this is the starting .00.

600
00:43:46,650 --> 00:43:49,680
And at this extreme point we have the higher value.

601
00:43:49,680 --> 00:43:52,980
So the maximum point of the width and the height is basically this point.

602
00:43:52,980 --> 00:43:54,180
This end point okay.

603
00:43:54,510 --> 00:43:59,820
So when we say that 783 is greater than 782 okay.

604
00:43:59,820 --> 00:44:00,750
So.

605
00:44:01,840 --> 00:44:03,670
Like you can see out here.

606
00:44:04,390 --> 00:44:09,520
Uh, if I just see, say, over here, that's 783 is greater than 782.

607
00:44:09,820 --> 00:44:15,190
So this basically means that we are traveling on the higher side over here.

608
00:44:15,220 --> 00:44:15,940
Okay.

609
00:44:16,030 --> 00:44:18,520
Because the previous was 783.

610
00:44:19,060 --> 00:44:20,680
Uh, the previous was 782.

611
00:44:20,680 --> 00:44:23,200
And now the latest was 783.

612
00:44:23,200 --> 00:44:25,450
So we are traveling in the south direction.

613
00:44:25,450 --> 00:44:25,900
Okay.

614
00:44:25,930 --> 00:44:29,410
The higher side, because here we have the maximum weight and the height.

615
00:44:29,410 --> 00:44:29,770
Okay.

616
00:44:29,830 --> 00:44:31,690
And when I say that.

617
00:44:33,780 --> 00:44:35,280
Now when I say that over here.

618
00:44:37,050 --> 00:44:44,160
So like you can see over here, I can say over here where the previous point.

619
00:44:47,720 --> 00:44:51,080
Oh, let me consider the case where we are traveling in the north direction.

620
00:44:56,000 --> 00:44:56,420
Like me.

621
00:44:56,420 --> 00:44:57,830
They are just so over here.

622
00:44:57,830 --> 00:45:01,460
Like you can see that this is 137 and 136.

623
00:45:01,460 --> 00:45:01,790
Okay.

624
00:45:01,790 --> 00:45:07,730
So the latest iteration is 136 and the previous iteration was uh, 137.

625
00:45:07,730 --> 00:45:08,180
Okay.

626
00:45:08,180 --> 00:45:15,650
So when there is 136 uh, so we are uh, just moving towards the north direction because in the over

627
00:45:15,650 --> 00:45:19,040
towards this, our height will be decreasing.

628
00:45:19,040 --> 00:45:19,490
Okay.

629
00:45:19,490 --> 00:45:23,060
So towards this our height will be decreasing in the north direction.

630
00:45:23,060 --> 00:45:25,160
Our height will be decreasing okay.

631
00:45:25,160 --> 00:45:29,540
And thus our direction, our height will be increasing like in the south direction.

632
00:45:29,540 --> 00:45:32,000
We will be, uh, going towards our maximum height.

633
00:45:32,000 --> 00:45:36,590
And in the north direction our height will be continuously decreasing.

634
00:45:36,590 --> 00:45:37,040
Okay.

635
00:45:39,140 --> 00:45:45,410
So like you can see over here, we have 137 and 136 for the latest iteration is 136.

636
00:45:45,410 --> 00:45:51,350
It means that we are going in the north direction and our height is constantly continuously decreasing.

637
00:45:51,350 --> 00:45:53,630
So here the vehicles are entering.

638
00:45:53,780 --> 00:45:56,960
So I have just added the same word over here.

639
00:45:56,960 --> 00:45:58,310
Is the south in direction.

640
00:45:58,310 --> 00:46:01,460
So the vehicles are leaving or the person is leaving.

641
00:46:01,460 --> 00:46:04,700
And if the north is direction then the person is entering over.

642
00:46:04,700 --> 00:46:05,990
The vehicles are entering.

643
00:46:05,990 --> 00:46:07,520
So the same code is being added.

644
00:46:07,520 --> 00:46:09,350
And here we are just finding the intersection.

645
00:46:09,350 --> 00:46:11,270
So when we say that uh.

646
00:46:13,090 --> 00:46:15,670
The center point of this car and this, like, intersect.

647
00:46:16,120 --> 00:46:16,510
Okay.

648
00:46:16,510 --> 00:46:18,940
So then we will just get better direction.

649
00:46:18,940 --> 00:46:25,840
In which direction the car or the vehicle is being, uh, the car, vehicle or person is being traveling.

650
00:46:25,840 --> 00:46:26,350
Okay.

651
00:46:26,350 --> 00:46:32,260
And here I've just displayed the count of above like the leaving count or entering count over here.

652
00:46:32,260 --> 00:46:39,550
So let me just run this complete script file and show you what output are we getting from here?

653
00:46:43,490 --> 00:46:44,510
Oh, let me just.

654
00:46:52,760 --> 00:46:53,030
It.

655
00:46:53,030 --> 00:46:55,910
So now we will be running on the.

656
00:47:00,070 --> 00:47:00,670
Okay.

657
00:47:00,700 --> 00:47:05,980
And I will just write you that image so that I can show you the output as well.

658
00:47:06,190 --> 00:47:08,800
And here we will be using a text box.

659
00:47:08,920 --> 00:47:11,950
For now we will be using S3 dot mp4.

660
00:47:11,950 --> 00:47:12,280
So.

661
00:47:42,410 --> 00:47:47,210
So now you can see that currently we don't like you can see the line drawn over here.

662
00:47:47,420 --> 00:47:49,070
And this is the wrong detection.

663
00:47:49,100 --> 00:47:49,700
Okay.

664
00:47:49,700 --> 00:47:53,750
So now you can see that here we have the center point of this car.

665
00:47:53,780 --> 00:47:55,220
You can see this green line.

666
00:47:55,640 --> 00:47:56,270
Okay.

667
00:47:56,690 --> 00:47:59,960
And here you can see the center point of this car as well.

668
00:48:03,640 --> 00:48:03,940
It.

669
00:48:08,730 --> 00:48:10,710
So let's go ahead.

670
00:48:10,710 --> 00:48:14,940
When the center point intersect with this line, then we will say the vehicle is entering.

671
00:48:14,940 --> 00:48:19,470
And when this center point intersect with this line, then we can say that the car is leaving.

672
00:48:19,590 --> 00:48:19,980
Okay.

673
00:48:29,220 --> 00:48:32,130
So let me just show you how this works.

674
00:48:34,720 --> 00:48:40,330
Okay so I'm using CPU so you can see the processing or the frame rate is very low.

675
00:48:57,050 --> 00:49:00,230
But when the center point intersects with this line, then we will see.

676
00:49:18,490 --> 00:49:23,350
So now you can see the center point as the center point intersect with this line.

677
00:49:24,010 --> 00:49:24,640
Okay.

678
00:49:24,940 --> 00:49:26,620
So the color of the line drawn wide.

679
00:49:26,620 --> 00:49:30,070
And you can see that we have the entering count of the car as one.

680
00:49:30,610 --> 00:49:31,210
Okay.

681
00:49:32,740 --> 00:49:38,020
And when this center point intersect with this line then we will have the leaving count of the car as

682
00:49:38,020 --> 00:49:38,710
one.

683
00:49:46,010 --> 00:49:50,660
And you can say that using a we are doing integrating object detection with object tracking and using

684
00:49:50,660 --> 00:49:51,800
Deepsort algorithm.

685
00:49:51,800 --> 00:49:57,350
Like you can see that we have assigned a unique ID seven to this object to this car, we have assigned

686
00:49:57,350 --> 00:49:58,850
a unique ID two to this car.

687
00:49:58,850 --> 00:50:01,250
We have assigned a unique ID 15 to this car.

688
00:50:01,370 --> 00:50:03,680
We have assigned a unique ID 16 to this car.

689
00:50:03,680 --> 00:50:06,770
We have assigned a unique ID to this type card.

690
00:50:06,770 --> 00:50:08,750
So this is what we do in object tracking.

691
00:50:08,750 --> 00:50:13,100
Now the object tracking we assign a unique value to each of the detected object.

692
00:50:13,100 --> 00:50:16,970
And then we track that object throughout the entire frame okay.

693
00:50:39,420 --> 00:50:45,870
Oh, I'm just waiting for this car to intersect with this line so that I can show you the living count

694
00:50:45,870 --> 00:50:47,190
over here as well.

695
00:50:52,840 --> 00:50:56,830
Now you can see that as the center point intersect with this line.

696
00:50:56,830 --> 00:51:00,250
Then we will see uneven count displayed over here as well.

697
00:51:12,860 --> 00:51:15,020
Okay, so now you can see the living count of card.

698
00:51:15,050 --> 00:51:20,660
So in this way you can count the vehicles entering and leaving our lane as well.

699
00:51:20,660 --> 00:51:23,930
So I will just test on other video as well.

700
00:51:23,930 --> 00:51:33,470
So before testing on other video like for the person counting, uh, let me just make one change the.

701
00:51:41,590 --> 00:51:47,650
So I'm just so here that different coordinates with persuading the video frame.

702
00:51:47,950 --> 00:51:48,310
Okay.

703
00:51:48,310 --> 00:51:56,290
So plus over here the line coordinates will also change or the dimensions of the line will also change.

704
00:51:56,290 --> 00:52:01,150
These are the starting point and this is the ending point of the line if.

705
00:52:03,540 --> 00:52:07,530
And now I will just writing test walk.

706
00:52:07,560 --> 00:52:08,250
Okay.

707
00:52:08,850 --> 00:52:10,950
And this is what the person.

708
00:52:11,220 --> 00:52:20,850
And so let's run this and let's see if you are able to do person counting and entering or leaving lane

709
00:52:20,850 --> 00:52:21,600
or not.

710
00:52:24,350 --> 00:52:24,650
If.

711
00:52:37,210 --> 00:52:37,810
Oh, yeah.

712
00:52:37,810 --> 00:52:41,050
You can see we have the video over here.

713
00:52:44,980 --> 00:52:45,250
Yet.

714
00:52:51,970 --> 00:52:52,270
Rod.

715
00:52:52,270 --> 00:52:54,940
You can see here we have the lane, the green lane.

716
00:52:54,940 --> 00:53:02,110
So when this person intersect with this line we will see a leaving cone displayed over here.

717
00:53:18,710 --> 00:53:19,820
So let's see.

718
00:53:19,820 --> 00:53:20,240
Order.

719
00:53:22,310 --> 00:53:27,890
So as this person intersect with this line and we'll see a living cone.

720
00:53:27,890 --> 00:53:30,710
And when this person intersect with this line we will see entering.

721
00:53:30,830 --> 00:53:33,680
So this person is traveling in the north direction.

722
00:53:33,680 --> 00:53:36,260
And this person is traveling a south direction.

723
00:53:36,260 --> 00:53:38,720
So in the south direction we'll have the living cow.

724
00:53:38,720 --> 00:53:41,060
And in the north direction we will have the entering cow.

725
00:53:47,240 --> 00:53:47,480
A.

726
00:53:52,070 --> 00:54:00,020
And you can see using object tracking, we have assigned a unique ID 517, 21 2519 1013 eight to each

727
00:54:00,020 --> 00:54:00,440
person.

728
00:54:00,440 --> 00:54:01,400
So let's see.

729
00:54:02,510 --> 00:54:03,560
Okay.

730
00:54:07,130 --> 00:54:10,070
Okay, so now you can see we have the entering out over here.

731
00:54:10,070 --> 00:54:14,900
And as this person intersect with this line we will have the leaving out should be over here.

732
00:54:15,860 --> 00:54:19,220
So now you can see the center point intersect with this line.

733
00:54:19,760 --> 00:54:23,990
Now you can see that we have the leaving count because this person have also crossed this line.

734
00:54:23,990 --> 00:54:25,940
So two person simultaneously crossed.

735
00:54:25,970 --> 00:54:30,350
We have the leaving count of person two and the entering count of the person as one.

736
00:54:30,860 --> 00:54:36,920
So now you can see over here we are able to complete the application where we are doing persons counting,

737
00:54:36,920 --> 00:54:41,480
entering and leaving a lane over the vehicles, counting and finger leaving a lane.

738
00:54:41,480 --> 00:54:42,920
So that's all from this tutorial.

739
00:54:42,920 --> 00:54:43,910
Thank you for watching.
