1
00:00:01,060 --> 00:00:06,460
In the previous cooling session, we implemented the step one of the localized state, which was extracting

2
00:00:06,460 --> 00:00:07,330
the background model.

3
00:00:07,840 --> 00:00:13,060
Now that we have extracted the bedroom model, we can move on to detecting our car and then extracting

4
00:00:13,060 --> 00:00:15,490
its location using background subtraction.

5
00:00:16,000 --> 00:00:18,730
For this, we move inside the localized board function.

6
00:00:19,120 --> 00:00:24,790
But after we have extracted the background, we implement the step to where it is foreground extraction.

7
00:00:26,290 --> 00:00:31,960
This is for detecting our car and this will be implemented using absolute difference.

8
00:00:31,960 --> 00:00:33,250
The Function of open series.

9
00:00:36,150 --> 00:00:41,250
Now what this function does is simply find the difference between two images and then fix their absolute.

10
00:00:41,670 --> 00:00:49,500
So for the source one, I'm going to be providing the current frame and for the source to our background

11
00:00:49,500 --> 00:00:49,800
world.

12
00:00:52,830 --> 00:00:55,500
This gives us change between both frames.

13
00:00:56,400 --> 00:01:02,130
So we need more times change now because the current Amazon BGR space.

14
00:01:02,340 --> 00:01:07,170
So the change will also be in BGR can space, but we're required in grayscale.

15
00:01:07,290 --> 00:01:11,620
So we will be using the open see function of convert color to convert it into grayscale.

16
00:01:11,640 --> 00:01:17,100
So once we have converted into grayscale, we now extract the mask of all the change objects in the

17
00:01:17,100 --> 00:01:17,460
frame.

18
00:01:17,790 --> 00:01:20,850
So that can be done by using function or thresholding.

19
00:01:21,510 --> 00:01:25,590
So severe to the threshold takes an input argument of sorts.

20
00:01:25,740 --> 00:01:29,100
That is our change group for the thrush.

21
00:01:29,460 --> 00:01:29,790
I'm going.

22
00:01:29,790 --> 00:01:35,820
I'm providing a measly value of 15 just to only ignore the values that are too small to see.

23
00:01:36,540 --> 00:01:43,080
And for the Maxwell the Maxwell you will be providing to 45 because we are looking to perform binary

24
00:01:43,080 --> 00:01:49,620
thresholding to get the mosque to change and type is binary thresh or thresh binary.

25
00:01:50,550 --> 00:01:55,790
And because thresholding provides two outputs and we are only interested in the second output when we

26
00:01:55,800 --> 00:01:58,410
are writing here one to get the second output.

27
00:01:58,980 --> 00:02:04,170
So the placeholder is change mask, which was our output.

28
00:02:04,560 --> 00:02:10,980
Now this change models not only contains the models of object that is the core, but also a lot of random

29
00:02:10,980 --> 00:02:11,340
noise.

30
00:02:11,940 --> 00:02:16,200
So because this noise is random, it will be in very small size.

31
00:02:16,470 --> 00:02:22,050
So we can leverage this information and only take the largest object that is our code and remove all

32
00:02:22,050 --> 00:02:22,500
the noise.

33
00:02:22,740 --> 00:02:26,580
And that can be done by using a function that is present inside this file.

34
00:02:27,180 --> 00:02:30,210
So we import that function that is return largest object.

35
00:02:31,200 --> 00:02:32,220
After importing it.

36
00:02:32,460 --> 00:02:38,460
We simply call that function of return largest object also in the chain models as input.

37
00:02:39,390 --> 00:02:41,010
And this gives me the two outputs.

38
00:02:41,310 --> 00:02:43,260
That is the largest object mask.

39
00:02:43,800 --> 00:02:44,790
That is the car mask.

40
00:02:46,290 --> 00:02:49,050
And the control is control.

41
00:02:50,310 --> 00:02:55,340
Now, once we have the mask and the control of the largest object, we can now extract this location

42
00:02:55,350 --> 00:02:58,380
or should as the relative location of the car to the myth.

43
00:02:59,010 --> 00:03:03,210
To do that, we'll be using a function that is good car location.

44
00:03:04,260 --> 00:03:10,020
Now get car location will take two inputs that it is the car control and the car mask.

45
00:03:11,310 --> 00:03:14,520
So we haven't defined this function yet, so we need to define it first.

46
00:03:14,850 --> 00:03:16,020
Let's define that function.

47
00:03:17,350 --> 00:03:19,300
So that is great collocation.

48
00:03:19,870 --> 00:03:21,370
The first is the car control.

49
00:03:22,660 --> 00:03:27,550
And second, or should I say the first is the self argument and then the car control.

50
00:03:27,550 --> 00:03:29,800
And the third argument is the car must.

51
00:03:32,200 --> 00:03:36,790
Now for the definition of this particular function, the very first thing that you need to do to get

52
00:03:36,790 --> 00:03:40,510
the location of any object, we need to find the centroid of that object.

53
00:03:41,170 --> 00:03:44,680
So we have to define the function, define centroid of object.

54
00:03:45,040 --> 00:03:48,940
So let's define the function that gets the centroid of any contour.

55
00:03:49,090 --> 00:03:50,890
So that is named as the centroid.

56
00:03:51,250 --> 00:03:53,770
What it does is simply takes a control of an object.

57
00:03:54,040 --> 00:04:00,520
Finest moments devise the first moment with the zeroth moment to get the centroid in the form of a tuple.

58
00:04:01,000 --> 00:04:08,590
So let's call this particular function by writing so that centroid mistakes in the input argument of

59
00:04:08,590 --> 00:04:11,710
the card counter and gives us.

60
00:04:12,820 --> 00:04:18,370
The centre of our board, so we name it as the center.

61
00:04:19,540 --> 00:04:23,920
Now that we have the ball center in the final two ball, this is the location of the car with respect

62
00:04:23,920 --> 00:04:24,410
to frame.

63
00:04:24,820 --> 00:04:28,060
But we require the relative location of the car with the means.

64
00:04:28,600 --> 00:04:34,450
So to get to that point, we need to perform the same transformation that we did to the myth that includes

65
00:04:34,450 --> 00:04:41,470
the translation of origin from frame two to the maze, and also the rotation to get the maze entry point

66
00:04:41,470 --> 00:04:41,890
on top.

67
00:04:42,430 --> 00:04:44,650
So to do that, we can't use this double.

68
00:04:44,650 --> 00:04:48,640
We did binary because the transformations need to be done on an entry.

69
00:04:48,880 --> 00:04:55,660
So we need to convert this tuple into an array and also we need to flip this tuple from and why x format

70
00:04:55,660 --> 00:05:01,260
to x y form, which is the formatting which which is used to perform all the transformations.

71
00:05:01,270 --> 00:05:03,280
So let's do both these things together.

72
00:05:03,580 --> 00:05:10,900
So right here we have simply converted the ball center that is a tuple to an array and also flip from

73
00:05:10,900 --> 00:05:13,330
y experiment to an x y format.

74
00:05:13,840 --> 00:05:18,070
We're taking the second value in the first and the first value the second.

75
00:05:18,670 --> 00:05:20,030
This gives us the ball center.

76
00:05:20,030 --> 00:05:25,170
Right now we have it in the format that we can now perform the transformations in the same way that

77
00:05:25,210 --> 00:05:27,400
form the transformations for our maze.

78
00:05:27,880 --> 00:05:30,940
So the first transformation is the translation of the origin.

79
00:05:31,390 --> 00:05:37,320
So that can be done by simply creating a placeholder at this box.

80
00:05:37,330 --> 00:05:45,430
Enter translated and that can be written as non point or zeros like the temporary.

81
00:05:48,110 --> 00:05:49,890
So we now have the placeholder.

82
00:05:49,910 --> 00:05:51,710
We simply need to do the translation.

83
00:05:52,190 --> 00:05:55,280
So that is simply written as more center translated.

84
00:05:55,760 --> 00:05:57,380
So we translate is force value.

85
00:05:57,590 --> 00:05:58,480
That is the x.

86
00:05:59,970 --> 00:06:01,140
By taking the ball central.

87
00:06:10,540 --> 00:06:19,090
While central areas first value and simply subtracting this with the origin origin column.

88
00:06:19,480 --> 00:06:25,990
So subtraction the more center column with the origin column simply gives us the translated more center

89
00:06:25,990 --> 00:06:28,960
column in the same way we'll be translating the rule.

90
00:06:28,960 --> 00:06:35,200
And once we closer to the row, we can now move on to the next step that is performing the rotation

91
00:06:35,380 --> 00:06:37,210
on our translated board center.

92
00:06:39,790 --> 00:06:46,270
So that we perform in the same way that we did with the translation that is using the previously saved

93
00:06:46,360 --> 00:06:51,030
or updated parameters that we did on that, we did transformations on our Ms..

94
00:06:51,520 --> 00:06:52,870
So that is for rotation.

95
00:06:52,870 --> 00:06:54,610
We have the rotation metrics.

96
00:06:55,090 --> 00:07:00,930
So we use that rotation metrics, use it to transform our ball center translator or rotate our bottom,

97
00:07:01,030 --> 00:07:04,180
translate it in the same way that we rotated our means.

98
00:07:05,050 --> 00:07:12,190
And then we transpose this and then transpose again to get this in the form of a nice little point.

99
00:07:12,610 --> 00:07:17,050
That is what location on Miss.

100
00:07:17,680 --> 00:07:21,160
So we now have the board relative location on the miss.

101
00:07:22,090 --> 00:07:22,420
So.

102
00:07:23,470 --> 00:07:24,910
They should completed right here.

103
00:07:25,150 --> 00:07:31,180
But because of rotation, there might come a point that is negative in its value, but location can

104
00:07:31,180 --> 00:07:31,990
never be negative.

105
00:07:32,200 --> 00:07:34,840
This is because the origin is shifted in the negative direction.

106
00:07:35,200 --> 00:07:36,860
So we want a positive value.

107
00:07:36,880 --> 00:07:39,190
So we need to translate this back.

108
00:07:39,190 --> 00:07:40,960
Or if it goes to negative.

109
00:07:42,360 --> 00:07:42,750
So.

110
00:07:43,970 --> 00:07:51,440
By simply adding the column rotation column to our core rules and adding the rules to our column, we

111
00:07:51,440 --> 00:07:54,440
can simply translate the origin if it gets to negative values.

112
00:07:55,040 --> 00:08:00,530
Now, once you've done this, simply need to save it inside the placeholder of the block location on

113
00:08:00,530 --> 00:08:00,920
the Miss.

114
00:08:01,130 --> 00:08:06,800
So that placeholder name is self-taught location GA and this stores the location of the core or relative

115
00:08:06,800 --> 00:08:08,390
location of the car on the miss.

116
00:08:09,110 --> 00:08:12,590
So we need to name this placeholder inside init function.

117
00:08:13,880 --> 00:08:14,690
So right here.

118
00:08:14,840 --> 00:08:16,160
So location, car.

119
00:08:17,000 --> 00:08:18,380
And it's like this to zero.

120
00:08:18,710 --> 00:08:21,920
So this will store the location of the car according to the myth.

121
00:08:22,400 --> 00:08:26,630
So now we know that we have completed the function of getting our location.

122
00:08:27,710 --> 00:08:31,640
We have called it right here in the localize but the main function of our localized state.

123
00:08:31,910 --> 00:08:37,580
We can move on to simply join the detected car so that we can see the user can see where the car is

124
00:08:37,580 --> 00:08:38,370
at any moment.

125
00:08:38,390 --> 00:08:44,510
So the way we do this is simply find the enclosing circle for the car control, draw that circle, and

126
00:08:44,510 --> 00:08:47,330
then simply display in the phone for a nice looking red color.

127
00:08:48,140 --> 00:08:51,410
Once we have done this, we display our detected car.

128
00:08:52,250 --> 00:08:58,220
So the localized car is shown on the frame display and also the foreground is being displayed clearly.

129
00:08:59,030 --> 00:09:03,710
So now we run this particular file around this project to see whether we have correctly implemented

130
00:09:03,920 --> 00:09:08,660
the state or the localized state for our problem solving.

131
00:09:08,930 --> 00:09:09,260
What?

132
00:09:11,280 --> 00:09:12,450
So we go inside the terminal.

133
00:09:14,140 --> 00:09:14,890
Will the project.

134
00:09:16,830 --> 00:09:18,010
Launch a simulation.

135
00:09:20,050 --> 00:09:24,640
So once the simulation starts up, we run our maze solver file.

136
00:09:25,700 --> 00:09:30,860
And as you can see, the male swallow part has run and it has correctly extracted a full step.

137
00:09:30,890 --> 00:09:32,030
It is a cracking starter.

138
00:09:32,270 --> 00:09:39,530
The males in the phone for me as entry on top and then perform just the next step that is stuck in the

139
00:09:39,530 --> 00:09:40,040
foreground.

140
00:09:40,130 --> 00:09:45,500
As you can see, the car has been correctly extracted from all of the noise and noise have been removed

141
00:09:45,800 --> 00:09:47,240
and only the car has been removed.

142
00:09:48,470 --> 00:09:49,850
And this is the mass of our car.

143
00:09:50,390 --> 00:09:55,280
So if you just look at the frame display, you can see that the car has been correctly localize right

144
00:09:55,280 --> 00:09:58,730
at the entry, the red circle drone on top of it.

145
00:09:59,180 --> 00:10:04,460
So we have found the location of the car relative to the means and this means we have correctly implemented

146
00:10:04,700 --> 00:10:10,730
the localised state of our assault and what so we can move on to the next step that is attempting the

147
00:10:10,730 --> 00:10:11,450
second stage.

148
00:10:11,480 --> 00:10:13,730
That is a mapping for our missile.

149
00:10:13,730 --> 00:10:15,050
Not till then.

150
00:10:15,290 --> 00:10:15,680
Thank you.

151
00:10:15,680 --> 00:10:16,070
And by.
