1
00:00:00,450 --> 00:00:05,250
OK, so now let's begin our fifth lesson, which is called transformations.

2
00:00:06,420 --> 00:00:11,640
So let's open this file is close off the previous four chapter and wait for this file to load.

3
00:00:12,210 --> 00:00:17,220
So what we're going to do in the chapter, we're going to do something basically called translations

4
00:00:17,220 --> 00:00:20,370
and rotations, which are the types of transformations.

5
00:00:20,370 --> 00:00:21,180
You can see it here.

6
00:00:21,190 --> 00:00:22,110
Transformations.

7
00:00:22,620 --> 00:00:30,090
What this means is that these are the manipulations where we actually alter or shift the image without

8
00:00:30,180 --> 00:00:35,400
actually interfering with anything of the aspect ratio of the original original image.

9
00:00:36,090 --> 00:00:41,790
So to begin, let's lower over functions here and download our images as we did previously.

10
00:00:42,690 --> 00:00:44,390
And let's take a look at translations.

11
00:00:44,400 --> 00:00:51,240
No transitions are an I find transform, which means that it just shifts the position of an image that

12
00:00:51,240 --> 00:00:56,490
doesn't affect it, doesn't warp the image in any way, doesn't change anything with the aspect ratio.

13
00:00:57,420 --> 00:01:01,650
It just basically moves it left or right or up and down.

14
00:01:02,490 --> 00:01:04,740
So you can see this is what this is.

15
00:01:04,740 --> 00:01:06,150
This how it works.

16
00:01:06,160 --> 00:01:10,500
Basically, it just actually multiplies this image here by this here.

17
00:01:10,710 --> 00:01:14,460
And what I find this is the function we used to do it called WARP.

18
00:01:14,490 --> 00:01:17,640
I find this matrix at T.

19
00:01:18,660 --> 00:01:20,940
Is this yeah, this is a translation matrix here.

20
00:01:21,480 --> 00:01:26,950
We're not going to get got to get into the mathematic terry between different matrices to do these things.

21
00:01:27,030 --> 00:01:34,160
However, what you should know is that this is this this dimension here where we have X and T y here

22
00:01:34,170 --> 00:01:36,330
and this matrix with the ones and zeros here.

23
00:01:36,810 --> 00:01:43,940
This multiplied by an image here gives us an actual shift in the image left and right or politically

24
00:01:43,950 --> 00:01:44,340
as well.

25
00:01:45,150 --> 00:01:46,350
So you can see that's slow.

26
00:01:46,360 --> 00:01:53,220
This image have me playing volleyball in a pool so we can load the image here and show the original

27
00:01:53,220 --> 00:01:53,970
image here.

28
00:01:54,450 --> 00:01:56,550
We get to get the height and weight of that image.

29
00:01:57,610 --> 00:01:58,710
Now that's what we're going to do.

30
00:01:58,720 --> 00:02:03,840
We're going to shift it by a quarter of the height and weight, basically.

31
00:02:04,350 --> 00:02:08,200
So what to do that we just get to height that we got here, divided by four?

32
00:02:08,250 --> 00:02:14,730
Similarly, for the width and that's what we're going to use for X and two y, we're going to shift

33
00:02:14,730 --> 00:02:22,140
the image basically a quarter of this full height up and then a quarter of its width to the right to

34
00:02:22,140 --> 00:02:22,530
right.

35
00:02:23,490 --> 00:02:26,370
So let's create our transition matrix here.

36
00:02:26,820 --> 00:02:28,260
You can see how we did it here before.

37
00:02:28,800 --> 00:02:31,110
So is a one zero one zero one two here.

38
00:02:31,350 --> 00:02:33,150
So that's how you can see this one zero.

39
00:02:33,390 --> 00:02:37,920
So this line then quarter to width, which is two x dimension, we're shifting again.

40
00:02:38,700 --> 00:02:47,220
Similarly, we have two zero and one, and Y is a political dimension of the direction we're moving.

41
00:02:47,850 --> 00:02:49,610
So we're moving at that quarter of the height.

42
00:02:49,620 --> 00:02:56,400
And as we said previously, we're going to use the CVT CV to go up our phone function here.

43
00:02:57,150 --> 00:02:58,530
Um, to do that.

44
00:02:58,860 --> 00:03:03,180
So you can see this is the inputs here within the height or to file image.

45
00:03:03,810 --> 00:03:06,900
And that's just run this magically.

46
00:03:07,740 --> 00:03:09,580
And you can see that it's here.

47
00:03:09,960 --> 00:03:13,440
So actually, when I started moving, it is going to be dissuaded actually with it this way.

48
00:03:13,830 --> 00:03:16,230
And that's because it's shifting from this reference point here.

49
00:03:16,290 --> 00:03:17,550
That's all you need to know.

50
00:03:18,210 --> 00:03:19,580
So this is pretty cool.

51
00:03:19,590 --> 00:03:23,790
Sometimes I naturally assumed the reference point is here because of the different libraries I use,

52
00:03:24,600 --> 00:03:26,760
but happens if it's at zero zero here.

53
00:03:27,690 --> 00:03:31,500
So you can see it pushed it this way exactly as we expected and wanted.

54
00:03:32,430 --> 00:03:36,420
So this is what he looks like here, and this is a bit of pride in what it looks like here in case you're

55
00:03:36,420 --> 00:03:38,520
wondering what our T.

56
00:03:38,640 --> 00:03:43,140
So this is the quarter with quarter height.

57
00:03:43,680 --> 00:03:50,460
And you can see the full height here for that here and zeros and ones as we looked at and or a translation

58
00:03:50,460 --> 00:03:51,750
matrix previously.

59
00:03:52,320 --> 00:03:54,480
So now let's take a look at rotations.

60
00:03:54,480 --> 00:03:59,700
And now OpenCV has this function called CV to Dot get rotation.

61
00:04:00,690 --> 00:04:07,470
Now this function is pretty cool and it actually takes the rotation center here of the X and Y point

62
00:04:07,620 --> 00:04:09,660
to a point you want to rotate about.

63
00:04:10,230 --> 00:04:14,940
So imagine there's a center point in the image or wherever you center point you want it to be.

64
00:04:15,810 --> 00:04:21,600
And that's a pivot point, and you just basically stick a pin here in the image and you just turn it

65
00:04:21,960 --> 00:04:24,150
on on on around at that point.

66
00:04:24,510 --> 00:04:29,610
That's where the rotation center is angular foundation and just how much rotation you want to do and

67
00:04:29,610 --> 00:04:31,080
scale basically changes.

68
00:04:31,080 --> 00:04:36,360
If you want to actually re scale this, resize the image, which we'll take a look at resizing quite

69
00:04:36,690 --> 00:04:39,300
quite soon in one of the chapters later on.

70
00:04:40,380 --> 00:04:45,300
So the notice, as applied, is rotation matrix to it, though let's see what we do.

71
00:04:45,330 --> 00:04:47,580
So what are we going to use for the arguments here?

72
00:04:48,000 --> 00:04:52,590
Let's use the center point to the center point would be would divide by two and a high divide by two.

73
00:04:53,060 --> 00:04:54,600
That's rotated 90 degrees.

74
00:04:54,600 --> 00:04:58,740
And I believe this 90 degrees is in a counterclockwise direction.

75
00:04:59,130 --> 00:04:59,850
So it's going to.

76
00:05:00,340 --> 00:05:01,300
Counterclockwise.

77
00:05:02,080 --> 00:05:05,560
And one here means a skill, which means we're keeping the same skill.

78
00:05:06,220 --> 00:05:13,390
So after we do this rotation matrix here, after we after we run this function here, get rotation matrix

79
00:05:13,390 --> 00:05:16,510
2D that gives us this rotation matrix.

80
00:05:16,900 --> 00:05:20,200
The rotation matrix is what we use now in the warp are fine.

81
00:05:20,800 --> 00:05:24,070
That's what we that we take this and use it as an input into the war.

82
00:05:24,070 --> 00:05:26,450
Baffling here to actually execute.

83
00:05:26,510 --> 00:05:31,780
So rotation function here to see rotation matrix function doesn't do the rotation, it just creates

84
00:05:31,780 --> 00:05:34,240
the matrix required to do the rotation.

85
00:05:34,810 --> 00:05:38,530
So let's run this now and you'll get this.

86
00:05:39,190 --> 00:05:50,380
So let's change something else changes to tree and this changes to a Nona like, let's just say, one

87
00:05:50,380 --> 00:05:51,190
two five.

88
00:05:52,300 --> 00:05:54,160
So let's see what that looks like.

89
00:05:54,700 --> 00:06:01,210
And you can see it rotated at a different point or point that's probably closer to here believe and

90
00:06:01,360 --> 00:06:03,790
tilted it into a different sort of a weird direction.

91
00:06:03,790 --> 00:06:05,590
Or you can't even see me in the picture anymore.

92
00:06:05,830 --> 00:06:06,490
I'm out of it.

93
00:06:07,210 --> 00:06:09,700
So let's bring it back to what it was before.

94
00:06:12,240 --> 00:06:22,260
And you get to get back on nicely rotated image, so you can see that basically to frame part of the

95
00:06:22,320 --> 00:06:27,630
image of missing from this frame if you wanted to keep the entire image in the frame now.

96
00:06:28,110 --> 00:06:30,300
That's why you use that's what a skill.

97
00:06:30,810 --> 00:06:33,360
You see this this last argument here called skill.

98
00:06:33,870 --> 00:06:34,700
That's what it does.

99
00:06:34,710 --> 00:06:36,690
It actually re scales the image a bit now.

100
00:06:37,290 --> 00:06:43,440
So it gives us a rotation matrix where there's a scaling factor involved, and that's actually pretty

101
00:06:43,440 --> 00:06:43,810
cool.

102
00:06:43,860 --> 00:06:45,240
We'll take a look at that afterward.

103
00:06:45,480 --> 00:06:46,590
I shall do it here.

104
00:06:48,010 --> 00:06:50,940
Let's bring this right here.

105
00:06:51,240 --> 00:06:51,750
Looks.

106
00:06:55,190 --> 00:06:59,270
And let's execute this now, so you can see this is what the rotation matrix looks like now.

107
00:06:59,720 --> 00:07:02,630
It's quite different to what we saw in the transmission matrix.

108
00:07:03,260 --> 00:07:05,570
So you can see it's doing, it's doing a number of things.

109
00:07:05,580 --> 00:07:10,290
It's doing the rotation along with skewing playing by doing this matrix.

110
00:07:10,340 --> 00:07:11,330
So that's pretty cool.

111
00:07:12,140 --> 00:07:14,520
So, no, you can begin with this.

112
00:07:14,520 --> 00:07:16,490
There's a lot of black space around the image.

113
00:07:17,000 --> 00:07:20,650
Now it is a weight around that is called CB2 transports.

114
00:07:21,140 --> 00:07:23,210
CB to transpose is actually quite cool.

115
00:07:23,240 --> 00:07:29,540
However, it is less flexible as in, we don't have as much control over what we want to do.

116
00:07:30,020 --> 00:07:32,000
So let's take a look at what it does.

117
00:07:32,180 --> 00:07:37,100
Leslie, you can see it just rotated the image here.

118
00:07:37,520 --> 00:07:44,810
It was hitting me like, actually, this is especially original image as well as side by side, so we

119
00:07:44,810 --> 00:07:47,000
can actually see, let's do this.

120
00:07:48,650 --> 00:07:53,640
Let's call this one the original website.

121
00:07:56,440 --> 00:08:02,770
And let's just use this as the image I should add, I'm making typos because I'm reaching around my

122
00:08:02,770 --> 00:08:04,840
microphone, it's quite awkward to do.

123
00:08:07,480 --> 00:08:09,160
So you can see this is how it looked.

124
00:08:09,640 --> 00:08:15,160
So you can see Transposed does something that does almost like a sort of like a flip in their actions.

125
00:08:15,610 --> 00:08:17,440
It flipped it left to right.

126
00:08:18,070 --> 00:08:20,950
You know, you know, that type of flip where it actually kind of mirrors it a bit.

127
00:08:21,650 --> 00:08:24,100
Imagine a mirror mirror was right on this side here.

128
00:08:24,700 --> 00:08:26,410
Oh, and that's kind of what it did.

129
00:08:26,500 --> 00:08:30,740
It puts it put me on the other side, and it rotated at the same time.

130
00:08:30,760 --> 00:08:32,770
So that's what a transpose function does.

131
00:08:33,310 --> 00:08:36,250
So it's not really even the best to think to use for rotation.

132
00:08:36,730 --> 00:08:41,500
They just supplies the transpose in case you ever needed for for it and for whatever purpose.

133
00:08:41,810 --> 00:08:42,080
OK.

134
00:08:44,330 --> 00:08:49,460
And you can apply twice and you get back what supposedly is the original image, and it should be.

135
00:08:49,970 --> 00:08:50,930
Yup, it is.

136
00:08:52,370 --> 00:08:58,910
So now this is an example of using transports to sort of rotate images, but not it's not true rotation.

137
00:08:59,480 --> 00:09:01,850
So now let's take a look at using Flip.

138
00:09:02,150 --> 00:09:08,990
The flip function does basically what I said transpose was doing the transposes, doing it in all aspects

139
00:09:09,110 --> 00:09:18,080
flip left to right and a flip basically a vertical rotation at 90 degrees at that point as well.

140
00:09:18,890 --> 00:09:21,920
So no flip basically does a horizontal flip.

141
00:09:22,340 --> 00:09:27,470
We imagine is a mirror like in the point center here, and that's what you're going to get the mirror

142
00:09:27,470 --> 00:09:29,090
image over here with me.

143
00:09:29,930 --> 00:09:32,240
So that's flip for you.

144
00:09:32,720 --> 00:09:34,380
And that's the end of this lesson.

145
00:09:34,380 --> 00:09:35,240
They hope you enjoyed it.

146
00:09:35,600 --> 00:09:40,030
We're going to move on to scaling, resizing and cropping and interpretations.

147
00:09:40,040 --> 00:09:42,770
So it's a big jump to the next next section.

148
00:09:42,780 --> 00:09:45,980
So stay tuned and hope you enjoyed it.

149
00:09:46,100 --> 00:09:46,490
Thank you.
